R水平打印删除外边框(调整打印边框)
我正在用levelplot(晶格)在R中创建关联热图。 我想要框之间的边框,但不要沿着外部,因为它会干扰绘图边框。 如何从框中删除外边框 这是我的密码:R水平打印删除外边框(调整打印边框),r,correlation,lattice,levelplot,R,Correlation,Lattice,Levelplot,我正在用levelplot(晶格)在R中创建关联热图。 我想要框之间的边框,但不要沿着外部,因为它会干扰绘图边框。 如何从框中删除外边框 这是我的密码: levelplot(matrix, border="black", colorkey=list(height=.25, space="right", at=seq(-1, 1, .25), cuts=7), scales=list(y=(list(cex=1)), tck = c(1,0), x=li
levelplot(matrix, border="black",
colorkey=list(height=.25, space="right", at=seq(-1, 1, .25), cuts=7),
scales=list(y=(list(cex=1)), tck = c(1,0), x=list(cex=1, rot=90)),
main="Leaf Correlations", xlab="", ylab="",
col.regions=scalebluered)
这是它的样子。。我不喜欢边上的双线
编辑:以下是一个可复制的示例:
data(mtcars)
cars.matrix <- as.matrix(mtcars[c(2:8)])
cars.corr <- cor(cars.matrix)
levelplot(cars.corr, border="black", colorkey=list(height=.25, space="right",
at=seq(-1, 1, .25), cuts=7),
scales=list(y=(list(cex=1)), tck = c(1,0), x=list(cex=1, rot=90)),
xlab="", ylab="")
数据(mtcars)
cars.matrix一点挖掘表演。例如,par(bty='n')
与基R图不同,格图不受par()函数中设置的许多选项的影响。要查看可以更改的选项,请查看帮助(xyplot)。在高级打印功能中设置这些选项通常是最简单的。。。可以编写修改面板渲染的函数
尝试使用此处建议的方法将轴颜色直接传递到图形中:
好的,如果有点模糊的话,这个问题的解决方法很简单
只需使用lattice.options()
重置用于因子的axis.padding
的值,将其默认值0.6(少量填充)更改为0.5(无填充),您应该可以:
lattice.options(axis.padding=list(factor=0.5))
## An example to show that this works
data(mtcars)
cars.matrix <- as.matrix(mtcars[c(2:8)])
cars.corr <- cor(cars.matrix)
levelplot(cars.corr, border="black", colorkey=list(height=.25, space="right",
at=seq(-1, 1, .25), cuts=7),
scales=list(y=(list(cex=1)), tck = c(1,0), x=list(cex=1, rot=90)),
xlab="", ylab="")
是否可以删除外部边界框?我的格子有点生锈,但可能类似于par.settings=list(axis.line=list(lwd=0)
,或者可能是col=“white”
maybe.Hmmm…这似乎可以去除所有的线条,包括记号…你有没有可能做出一个最小的重复示例?@JoshO'Brien-添加了一个示例..谢谢。添加了一个答案;)谢谢!我不知道我会不会明白这一点!同时,我发现corrplot库有一些很好的选项,对我来说,这可能是一条比根据需要定制levelplot更好的途径。使用上面的例子,这也得到了我想要的:library(corrplot)corrplot(cars.corr,method=“shade”,shade.col=NA,tl.col=“black”,tl.srt=45,addgrid.col=“black”)
@Paul——可以理解,虽然我刚刚添加了一些注释,希望您和其他人能够更容易地再现引导我选择该选项的思考过程。不知道它在这个特定实例中是否有效,但摆脱轴线的完整选项是par.settings=list(axis.line=list(col=“transparent”)
。
lattice.options(axis.padding=list(factor=0.5))
## An example to show that this works
data(mtcars)
cars.matrix <- as.matrix(mtcars[c(2:8)])
cars.corr <- cor(cars.matrix)
levelplot(cars.corr, border="black", colorkey=list(height=.25, space="right",
at=seq(-1, 1, .25), cuts=7),
scales=list(y=(list(cex=1)), tck = c(1,0), x=list(cex=1, rot=90)),
xlab="", ylab="")
head(prepanel.default.levelplot, 4)
1 function (x, y, subscripts, ...)
2 {
3 pad <- lattice.getOption("axis.padding")$numeric
4 if (length(subscripts) > 0) {