R - How to draw an empty plot?

From time to time I need to make an empty plot. This is the best I could think of.

plot(0,xaxt='n',yaxt='n',bty='n',pch='',ylab='',xlab='') 

Any simpler solutions?

ps 1: completely empty, no axis, etc.

Thank!

+68
r plot
Jan 24 '11 at 18:31
source share
8 answers

How about something like:

 plot.new() 
+71
Jan 24 '11 at 18:39
source share

I suggest that someone should make an 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 axis boundaries of your graphics.

+32
May 01 '14 at 13:50
source share

Adam, following your comment above ("I wanted the blank plot to serve as a placeholder in the mfrow plot."), What you really want is the mfg option

  par(mfg=c(row,column)) 

- which controls where you want to place the next plot. For example, to place a graph in the middle of a 3x3 multiplexer, do

  par(mfrow=c(3,3)) par(mfg=c(2,2)) plot(rnorm(10)) 
+15
Oct 10 '12 at 9:13
source share

This is a bit simpler than your original solution:

 plot(0,type='n',axes=FALSE,ann=FALSE) 
+15
Jun 01 '14 at 23:32
source share

Below nothing is displayed 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 if you want to add lines or dots after a for loop or something similar. Remember to change the xlim and ylim based on the data you want to build.

+9
Feb 09 '15 at 12:21
source share

You need a new graph window, as well as a coordinate system, so you need plot.new() and plot.window() , after which you can start adding graph elements:

 plot.new( ) plot.window( xlim=c(-5,5), ylim=c(-5,5) ) points( rnorm(100), rnorm(100) ) axis( side=1 ) 

rough schedule

+5
Oct 6 '16 at 4:58
source share

There is an interest in your decision that plot.new() does not have: you can write text in the given coordinates using the text(x = ..., y = ..., your_text) on the empty plot that you "draw" .

+3
Feb 28 '13 at 12:21
source share
 grid.newpage() ## If you're using ggplot grid() ## If you just want to activate the device. 
+2
Jan 25 '11 at 5:52
source share



All Articles