[R] Changing a plot

Ben Bolker bolker at ufl.edu
Wed Sep 24 16:12:28 CEST 2008


R Help <rhelp.stats <at> gmail.com> writes:

> 
> Hello list,
> 
> I've been working on this problem for a while and I haven't been able
> to come up with a solution.
> 
> I have a couple of functions that plot a bunch of data, then a single
> point on top of it.  What I want is to be able to change the plot of
> the point without replotting all the data.  Consider the following
> example:
> 
> x = rnorm(100,1,0.5)
> y = rnorm(100,1,0.5)
> plot(x,y,pch=16)
> points(x[35],y[35],pch=19,col=6,cex=3)
> 
> What I want to be able to do is to change the purple point to a
> different value without replotting everything.
> 

  R's default (base) graphics model is a 'canvas' -- things get
drawn, but nothing ever gets erased. (The cheap solution is
to overplot in the background color, but that 
won't work if there's stuff underneath the point
that you want to preserve.) You probably need to move
to the grid graphics package (hint: buy or borrow Paul Murrell's
book) to do something like this.

  Ben Bolker



More information about the R-help mailing list