R:格函数中的图例

Arn*_*rne 3 r legend lattice colorbar

我用 R 的格子包可视化了一个矩阵,以获得 10x10 的网格。

不幸的是,我确实在微调方面遇到了一些问题。

颜色条需要一个解释性标题(垂直写在它旁边)。

这是一个示例代码,可以看看它现在的样子以及一张图片。

library(lattice)

#Build the horizontal and vertical axis information

hor=c("0.0005", "0.001", "0.005", "0.01", "0.05", "0.1", "0.5", "1", "5", "10")
ver=c("1000","2000","3000","4000","5000","6000","7000","8000","9000","10000")

nrowcol=length(ver)
cor = matrix(runif(nrowcol*nrowcol, min=0.4), nrow=nrowcol, ncol=nrowcol, dimnames = list(hor, ver))
for (i in 1:nrowcol) cor[i,i] = 1

rgb.palette <- colorRampPalette(c("blue", "yellow"), space = "rgb")
levelplot(cor, col.regions=rgb.palette(120), cuts=100, at=seq(0,1,0.01),
          xlab=expression("DAG depletion rate k"[B49] *" [ s"^"-1"*" ]"),
          ylab=expression("PKC activation rate k"[D5] *" [ l / (mol*s) ]"))
Run Code Online (Sandbox Code Playgroud)

你猜我该如何解决这些小问题吗?

最好,非常感谢!

在此输入图像描述

G. *_*eck 5

添加这些行,根据需要调整 x 和 y 位置:

library(grid)
grid.text("Here is some text explaining the legend", .77, .5, rot = 270)
Run Code Online (Sandbox Code Playgroud)

截屏