
Last chance! 50% off unlimited learning
Sale ends in
Clip plotting to a rectangular region that is a subset of the plotting area
clipplot(fun, xlim = par("usr")[1:2], ylim = par("usr")[3:4])
Nothing meaningful is returned
The function or expression to do the plotting.
A vector of length 2 representing the x-limits to clip plotting to, defaults to the entire width of the plotting region.
A vector of length 2 representing the y-limits to clip the plot to, defaults to the entire height of the plotting region.
Greg Snow 538280@gmail.com
This function resets the active region for plotting to a rectangle within the plotting area and turns on clipping so that any points, lines, etc. that are outside the rectange are not plotted.
A side effect of this function is a call to the box()
command,
it is called with a fully transparent color so if your graphics device
honors transparency then you will probably see no effect.
x <- seq(1,100)
y <- rnorm(100)
plot(x,y, type='b', col='blue')
clipplot( lines(x,y, type='b', col='red'), ylim=c(par('usr')[3],0))
attach(iris)
tmp <- c('red','green','blue')
names(tmp) <- levels(Species)
plot(Petal.Width,Petal.Length, col=tmp[Species])
for(s in levels(Species)){
clipplot( abline(
lm(Petal.Length~Petal.Width, data=iris, subset=Species==s),
col=tmp[s]),
xlim=range(Petal.Width[Species==s]))
}
detach(iris)
Run the code above in your browser using DataLab