How to draw an empty plot?
This is marginally simpler than your original solution:
plot(0,type='n',axes=FALSE,ann=FALSE)
How about something like:
plot.new()
I suggest that someone needs to make empty plot in order to add some graphics on it later. So, using
plot(1, type="n", xlab="", ylab="", xlim=c(0, 10), ylim=c(0, 10))
you can specify the axes limits of your graphic.
The following does not plot anything in the plot and it will remain empty.
plot(NULL, xlim=c(0,1), ylim=c(0,1), ylab="y label", xlab="x lablel")
This is useful when you want to add lines or dots afterwards within a for
loop or something similar. Just remember to change the xlim
and ylim
values based on the data you want to plot.
As a side note:
This can also be used for Boxplot, Violin plots and swarm plots. for those remember to add add = TRUE
to their plotting function and also specify at =
to specify on which number you want to plot them (default is x axis unless you have set horz = TRUE
in these functions.