如何在 lattice R 中隐藏 x 轴

5
如何在 lattice xyplot 中隐藏 x 轴(xlim )?正常情况下,这可以通过以下代码实现:
hist(rnorm(10,0,2), axes=F)

如果您有很多图形需要处理,那么全局解决方案会非常好。我正在使用gridExtra包:

grid.arrange(plot1,plot2,plot3, ncol=3)

例如,这允许隐藏xlab、ylab和main

pl = list(plot1,plot2,plot3)
do.call(grid.arrange, lapply(pl, update, xlab="", ylab="", main=""))

以下是示例数据:

Data <- data.frame(x=rnorm(10,2,2),y=rnorm(10,3,3),z=rexp(10,2))
plot1 <- xyplot(x~y, Data, xlab="name", ylab="name", main="title")
plot2 <- xyplot(z~y, Data, xlab="name", ylab="name", main="title")
plot3 <- xyplot(z~x, Data, xlab="name", ylab="name", main="title")

全局隐藏也可以在上面的print()中显示,或者其他所有这些内容都有帮助。

“suppress xlim”是什么意思?更改绘图的x范围与清除注释完全不同,说它被“抑制”真的没有任何意义。 - IRTFM
好的,我的意思是不在图上显示xlim,而实际上使用xlim设置。 - Maximilian
所以我现在已经更改了描述,希望现在清楚了。谢谢。 - Maximilian
1
有点偏题,但是要删除y轴,这就是我必须做的:scales = list(relation = "free", y = list(draw = FALSE)) - Waldir Leoncio
2个回答

8

试试这个

xyplot(1:10~1:10, scales=list(x=list(at=NULL)))

you should read the docs in ?xyplot


3
我已经阅读了格子图手册,但是xyplot的设置如此广泛,就像阅读小说一样。 - Maximilian
其实,我一直在使用“scales”来微调xlim,但从未想过只需设置“at=NULL”就可以如此简单明了。当然,您的解决方案适用于我的帖子中的全局命令。非常感谢。 - Maximilian

8
您可以尝试使用以下代码:xyplot(1:10~1:10, scales=list(x=list(draw=FALSE)))

这个解决方案更好,至少在 dotplothorizontal=FALSE 的情况下是如此,因为 dotplot(1:10~1:10, horizontal=FALSE, scales=list(x=list(at=NULL))) 不会抑制 x 轴,但是 dotplot(1:10~1:10, horizontal=FALSE, scales=list(x=list(draw=FALSE))) 会。 - Bryan

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接