[英]Plots without titles/labels in R
In R is there any way to produce plots which have no title and which use the space the title would otherwise have taken up? 在R中,有什么方法可以生成没有标题的图,并使用标题原本会占用的空间?
In plot()
, main
, sub
, xlab
, and ylab
all default to NULL
, but this just leaves blank space where they would have been, ditto for setting them to ''. 在
plot()
, main
, sub
, xlab
和ylab
都默认为NULL
,但这仅留了空白,将它们设置为”。 It would be nice if not including them meant that the entire plot space was utilized rather than leaving extra empty space on the edges. 如果不包括它们,那就意味着可以利用整个绘图空间,而不是在边缘保留多余的空白,那将是很好的。 This is all especially relevant in printing plots to file devices like
pdf()
, png()
, etc. 这在将绘图打印到
pdf()
, png()
等文件设备时特别重要。
If you're willing to entertain an alternate plotting package, ggplot2 does this automatically when you set xlab
/ ylab
to NULL
(and there is no plot title/ main
by default). 如果您愿意接受一个替代的绘图程序包, 那么当您将
xlab
/ ylab
设置为NULL
(并且默认情况下没有绘图标题/ main
)时, ggplot2会自动执行此操作。 For simple plots, just require(ggplot2)
and replace plot
by qplot
. 对于简单的绘图,只需
require(ggplot2)
并用qplot
替换plot
。
Really, ggplot2 is the most fun I've had with plotting in years and I can't resist the opportunity to evangelize it to everyone I meet. 确实,ggplot2是我多年来进行绘图所获得的最大乐趣,我无法抗拒将它传播给与我见面的每个人的机会。 :-)
:-)
With lattice, it's just a matter of setting the xlab, ylab, and main arguments to NULL: 使用格子时,只需将xlab,ylab和主要参数设置为NULL即可:
library(lattice)
bwplot(rnorm(100),xlab=NULL,ylab=NULL,main=NULL)
plot(anything, main=NULL)
仍然有效。
I usually use 我通常使用
par(mar=c(1,1,1,1))
when I keep the border to a minimum. 当我将边界最小化时。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.