[R] Defining a viewport scale in {Grid}

geotheory geotheory1 at gmail.com
Thu Feb 16 14:47:38 CET 2012


Am just feeling my way into the grid library, and cannot figure out how to
define the plot limits.  3/5 of the example polygons below plot in the
default 0-1 range viewport.  But when I try to redefine the viewport the
polygons plot in the same places.  I also get the same result without
employing push/pop.  (As you can see from the scale I'm trying to introduce,
I want to plot map polygons.)  Grateful for an idea where I'm going wrong.

pushViewport(viewport(xscale=c(-180,180),yscale=c(-90,90)))

grid.polygon(x=c(0,5,5,0)/100, y=c(0,0,5,5)/100, draw = T)
grid.polygon(x=c(100,95,95,100)/100, y=c(100,100,95,95)/100, draw = T)
grid.polygon(x=c(50,70,70,50)/100, y=c(50,50,70,70)/100, draw = T) 
grid.polygon(x=-c(10,10,40,40)/100, y=c(10,40,40,10)/100, draw = T)
#NEGATIVE X
grid.polygon(x=c(50,52,52,50)/100, y=-c(50,50,52,52)/100, draw = T)
#NEGATIVE Y

popViewport()

Thanks in advance.

--
View this message in context: http://r.789695.n4.nabble.com/Defining-a-viewport-scale-in-Grid-tp4393974p4393974.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list