[R] deleting an arow added to a graphic

Duncan Murdoch murdoch at stats.uwo.ca
Wed Sep 6 21:33:52 CEST 2006


On 9/6/2006 3:04 PM, Graham Smith wrote:
> I know this has got to be simple, but I have a added  an arrow to a graph
> with:
> 
> arrows(5,8,8, predict(lmfit,data.frame(x=8)), length=0.1)
> 
> but its in the wrong position, correcting it and running again adds an new
> arrow (which is what you would expect) so how do I
> 
> a) edit the existing arrow, and
> b) delete it all together
> 
> As so often seems to be the case, some of the simplist things seem also to
> be the most difficult to find the answer to.
> 

Generally "classic" graphics in R are like drawing in ink on paper:  you 
can't remove items that you've drawn there.

So the way to do what you want is to save the commands that produced the 
  entire graph, and edit them until you get them right.  Then you can 
run them and produce a new graph that's just right.

grid allows items to be removed from an existing graph, so lattice and 
ggplot inherit this nice property.  rgl (for 3d graphics) also allows 
items to be removed in a fairly inflexible way (only in the reverse 
order of the order drawn); the next release will make this more flexible.

Duncan Murdoch



More information about the R-help mailing list