Skip to content

grid: clipping points to viewport?

3 messages · M.Kondrin, Paul Murrell

#
Why command 
grid.points(c(0,1,1.1),c(0,1,1.1),vp=viewport(w=0.5,h=0.5,x=0.5,y=0.5,clip=TRUE)) 
does not clip points (point (1.1,1.1) is still visible), although there 
is no problem with grid.lines(...)?
And one more question - how can I swap direction of tick marks on 
grid.x(y)axis to turn it inside plot?
#
Hi
M.Kondrin wrote:

            
What version/device is this happening on?
This works for me (R 1.6.2, X11/postscript)
If I understand what you mean, there is no argument to grid.x(y)axis 
that will do what you want.  This is something that should probably be 
added at some piont.  For now, it is pretty straightforward to do 
something by hand.  The following may help ...

push.viewport(viewport(w=0.5,h=0.5,x=0.5,y=0.5))
x <- rnorm(10)
y <- rnorm(10)
push.viewport(dataViewport(x, y))
grid.rect(gp=gpar(col="grey"))
grid.points(x, y)
tick.loc <- grid.pretty(range(x))
grid.segments(unit(tick.loc, "native"),
               0,
               unit(tick.loc, "native"),
               unit(0.5, "lines"))
grid.lines(unit(range(tick.loc), "native"), 0)
grid.text(tick.loc, unit(tick.loc, "native"),
           unit(-0.5, "lines"))
pop.viewport(2)


Paul
#
Paul Murrell wrote:

            
Paul -thank you very much!
Problem with clipping happens when I use gtk() device from Omegahat 
RGtkDevice (R ver. 1.6.1). I think I should address this question to them.