我正在尝试使用numpy数组中的数据,使用rpy2和lattice来创建热图或颜色强度图。我使用的是python2.6.2、r2.10.1、rpy2.1.9,不确定是哪个版本的lattice。我已经让它工作得很好了,除了我需要修改用于绘制相关变量(z)级别的颜色渐变的默认晶格设置。具体地说,我想要灰度而不是品红色青色的默认渐变。下面是生成虚拟数据帧并在vanillar R中创建灰度级图的代码:
library(lattice)
x <- rep(seq(1,10), each=10)
y <- rep(seq(1,10), 10)
z <- abs(rnorm(100))
z <- z/max(z)
df <- data.frame(x=x, y=y, z=z)
grayvector <- gray(seq(0,1,1/100))
foo <- levelplot(z ~ x * y, data=df, col.regions = grayvector)
print foo
使用rpy2时,我无法设置col.地区争论。根据文档,rpy2应该转换任何。“”的函数参数中的字符。然而,这似乎行不通,因为使用col_nu区域会导致参数被忽略。以下是生成levelplot的python代码,但没有灰度:
^{pr2}$有人知道如何将格函数参数与a一起使用吗。在rpy2里?在
需要手动指定参数映射:
{同时检查}
相关问题 更多 >
编程相关推荐