[R] Changing a plot

Adaikalavan Ramasamy a.ramasamy at imperial.ac.uk
Wed Sep 24 16:19:54 CEST 2008


One way is to keep a copy of the original and then return to it when you 
need it.

  x <- rnorm(100,1,0.5)
  y <- rnorm(100,1,0.5)
  plot(x,y,pch=16)
  original <- recordPlot()

  for( i in 1:10 ){
    points( x[i], y[i], pch=19, col="yellow", cex=3)
    points( x[i], y[i], pch=16)
    Sys.sleep(1)                  # slow the graphs a bit
    replayPlot(original)
  }

Regards, Adai



R Help wrote:
> 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.
> 
> I know this seems like an odd suggestion, but it comes up a lot with
> the work I'm doing.  I've prepared a package on CRAN called
> ResearchMethods for a course I'm working on, and there are several
> functions in there who's GUIs could work better if I could figure this
> out.
> 
> If anyone has any ideas, or needs some further explanation, feel free
> to contact me.
> 
> Thanks a lot,
> Sam Stewart
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list