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?
grid: clipping points to viewport?
3 messages · M.Kondrin, Paul Murrell
Hi
M.Kondrin wrote:
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(...)?
What version/device is this happening on? This works for me (R 1.6.2, X11/postscript)
And one more question - how can I swap direction of tick marks on grid.x(y)axis to turn it inside plot?
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
Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 paul at stat.auckland.ac.nz
Paul Murrell wrote:
Hi M.Kondrin wrote:
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(...)?
What version/device is this happening on? This works for me (R 1.6.2, X11/postscript)
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.