Plots without titles/labels in R
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). For simple plots, just require(ggplot2)
and replace plot
by qplot
.
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. :-)
See tip 7 about adjusting the margins.
Excerpt:
To remove the space reserved for labels, use par(mar=...). For example
png(file="notitle.png",width=400, height=350)
par(mar=c(5,3,2,2)+0.1)
hist(rnorm(100),ylab=NULL,main=NULL)
dev.off()
With lattice, it's just a matter of setting the xlab, ylab, and main arguments to NULL:
library(lattice)
bwplot(rnorm(100),xlab=NULL,ylab=NULL,main=NULL)