One of the things that most bugs me about R is the separation of the plot, points, and lines commands. It's somewhat irritating to have to change plot to whatever variant for the first plot done, and to have to replot from scratch if you failed to have set the correct the ylim and xlim initially. Wouldn't it be nice to have one command that:
Picks lines, points or both via an argument, as in
plot(..., type = "l")
?By default, chooses whether to create a new plot, or add to an existing one according to whether the current device is empty or not.
Rescales axes automatically if the added elements to the plot exceed the current bounds.
Has anyone done anything like this? If not, and there's no strong reason why this isn't possible, I'll answer this myself in a bit...
Some possible functionality that may help with what you want:
The
matplot
function uses base graphics and will plot several sets of points or lines in one step, figuring out the correct ranges in one step.There is an
update
method for lattice graphics that can be used to add/change things in the plot and will therefore result in automatic recalculation of things like limits and axes.If you add additional information (useing
+
) to a ggplot2 plot, then the things that are automatically calculated will be recalculated.You already found
zoomplot
and there is always the approach of writing your own function like you did.