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?

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 ''. 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.

12/15/2016 12:15:49 AM

Accepted Answer

See tip 7 about adjusting the margins.


To remove the space reserved for labels, use par(mar=...). For example

png(file="notitle.png",width=400, height=350)
4/10/2009 3:15:17 AM

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. :-)

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow