Learn R Programming

plotrix (version 2.6-1)

emptyspace: Find an empty space on a plot.

Description

Try to find the largest empty rectangle on a plot.

Usage

emptyspace(x,y=NA,bars=FALSE)

Arguments

x,y
x and y positions of the points or centers and heights of the bars
bars
Whether to add x and y points to represent the bars if the plot is a barplot.

Value

  • The x and y coordinates of the center of the rectangle found.

Details

emptyspace divides the area defined by par("usr") into smaller and smaller rectangles until at least one rectangle has no points defined by x and y within it. It then tries to find the largest such rectangle if more than one exists and calculates its center. If the plot is very crowded, the resulting rectangle may be very small. emptyspace will accept a list of at least two matrices as if it was returned from brkdn.plot, calculate the positions of the ends of the dispersion bars and then try to find an empty rectangle. It will also accept a list of x-y coordinates, looking for the first element to have the name x, and set y to the second element. Note that if there are any NAs in x or y, emptyspace will fail.

Examples

Run this code
x<-rnorm(10)
 y<-rnorm(10)
 plot(x,y,main="Find the empty space",xlab="X",ylab="Y")
 es<-emptyspace(x,y)
 boxed.labels(es,labels="Here is the
empty space")

Run the code above in your browser using DataLab