[R] plotting and unplotting lines in R

Alejandro Munoz del Rio munoz at stat.wisc.edu
Mon Jan 13 18:07:06 CET 2003


"RexBryan" <rexbryan1 at attbi.com> writes:
> I would like to plot and unplot a line to a graph using R's line
> command.    This would allow for sequentially trying different plotted
> functions for a visual fit.  Is there a way to do this?

you can try re-plotting the line you want to erase in the color that matches
the bacground, e.g.
x <- rnorm(100)
plot(x)
lines(1:100, cos(1:100))
# assess quality of fit, then erase:
lines(1:100, cos(1:100), col="white")
# draw next fit
lines(1:100, sin(1:100))

the solution isn't "clean" in that erasing the line may also erase some of
the points. to prevent this, use
points(x), or re-plot altogether via plot(x)

hope this helps,

alejandro




More information about the R-help mailing list