Is it possible to change the ylim and xlim when the plot has already been drawn?

(Just for completeness.)

This is almost certainly impossible in R base graphics. Other answers point out that it's doable in ggplot. It might be possible in something like the playwith package, although a short bit of playing around hasn't shown me a way to do it.


You can alter the axes limits in ggplot2. For example,

require(ggplot2)
data(mpg) 

g = ggplot(mpg, aes(cyl, cty)) + geom_point() + xlim(5, 8)
g
g + xlim(4,8)

As Ben Bolker mentions, in base graphics, you definitely can't do it without additional packages.

Tags:

Plot

R

Limit