Skip to content

How to plot a blank plot

7 messages · Chuck Cleland, Adrian Custer, Don MacQueen +2 more

#
Hello everyone,

In plotting several graphics, I'd like to be able to plot a blank plot
as in:

par(mfrow=c(2,1))
plot(BLANK)
hist(rgamma(100000,6463.7,scale=0.015471),xlim=c(0,120),main="Emergence")

I realize screen allows me to do this, but I figure the functionality
must be there. Is there an equivalent to plot(BLANK)?

thanks,
adrian

PS. please reply direct as I'm not subscribed to the list.
#
Adrian Custer wrote:

            
par(mfrow=c(2,1))
frame()
hist(rgamma(100000,6463.7,scale=0.015471),xlim=c(0,120),main="Emergence")

see ?frame
#
On Fri, 2004-02-13 at 14:11, Adrian Custer wrote:
Try either:

par(mfrow=c(2,1))
frame()
hist(rgamma(100000,6463.7,scale=0.015471),xlim=c(0,120),main="Emergence")

or 

par(mfrow=c(2,1))
plot.new()
hist(rgamma(100000,6463.7,scale=0.015471),xlim=c(0,120),main="Emergence")

See ?plot.new or ?frame, which will lead you to the same help page.

HTH,

Marc Schwartz
#
frame() it is!

I suspected there would be something simple. :-)

Thanks everyone.

--adrian
On Fri, 2004-02-13 at 12:28, Chuck Cleland wrote:
#
And although frame() is obviously the better way, if you really 
wanted to know what to put inside plot(), this will do it:

    plot(1, type='n', xaxt='n', yaxt='n', xlab='', ylab='', bty='n')

-Don
At 12:41 PM -0800 2/13/04, Adrian Custer wrote:

  
    
#
On Fri, 2004-02-13 at 15:31, Don MacQueen wrote:
A slightly shorter version of the same thing is:

plot(1, ann = FALSE, axes = FALSE, type = "n")

This gives you a blank plot area with the following, perhaps most
important, par value:
[1] 0.568 1.432 0.568 1.432


plot.new() and frame() give you the following:
[1] -0.04  1.04 -0.04  1.04

Recall that par("usr") is c(x1, x2, y1, y2).


In either case, the above values can be overridden by a subsequent call
to par("usr"), such as the following:

par(usr = c(0, 1, 0, 1))

Thus setting the x and y ranges to known values if one needs them a
particular way.  

Another way of accomplishing the same thing with a single function call
is:

plot(1, ann = FALSE, axes = FALSE, xlim = c(0, 1), ylim = c(0, 1), 
     type = "n", xaxs = "i", yaxs = "i")

The use of 'xaxs' and 'yaxs' sets the ranges of the x and y axes to
exactly the limits specified, rather than extending both by 4%, which is
the default (with values of "r"). This yields:
[1] 0 1 0 1

instead of:
[1] -0.04  1.04 -0.04  1.04

as seen above from a default call to plot.new() or frame().

So, ultimately, if you are not going to actually draw anything in the
particular plot region as is Adrian's situation, such that you are not
concerned with the coordinates and other details, plot.new() and frame()
are the quickest as Don, I and others have pointed out. 

Indeed, as ?frame points out:

"...('frame' is an alias for 'plot.new')..."
function () 
.Internal(plot.new())
<environment: namespace:base>


So which one you pick is really a personal preference choice. As is the
case frequently with R, there is more than one way to get to the same
end point, some more 'elegant' than others.

HTH,

Marc Schwartz
#
On Fri, 13 Feb 2004 12:11:26 -0800, you wrote:

            
"frame()" is probably what you want.

You can also get a blank plot (but set up coordinates, etc.) with
something like

plot(1, type="n", axes=F, xlab="", ylab="")

This would allow you to plot points and lines and text in the empty
space; frame() would not.

Duncan Murdoch