[R] help with using grid.polygon()
David Winsemius
dwinsemius at comcast.net
Wed Aug 4 15:43:44 CEST 2010
On Aug 4, 2010, at 9:32 AM, Ally wrote:
>
> Hi,
>
> I'm trying to use grid.polygon() to plot several polygons at once,
> with a
> view to putting coloured polygons beneath a curve. I'm struggling
> just to
> get the grid.polygon to plot anything
>
> # PLOT SOME POINTS
> x <- 1:100
> y <- 1:100*0.5 + 3
> plot(x, y, pch = ".")
>
> # PLOT 2 POLYGONS
> library(grid)
> grid.polygon(x = c(20, 20, 40, 40, 40, 40, 60, 60),
> y = c(0, 10, 20 , 0, 0, 20, 30, 0), id = rep(1:2,
> each =
> 4), draw = T)
>
> I'm wondering whether this is to do with the 'id' parameter, if I've
> misunderstood it's use - but any hep would be greatly appreciated!
Your x and y locations are so large they are off the page. Compare:
grid.polygon(x = c(20, 20, 40, 40, 40, 40, 60, 60)/100,
y = 0.5+c(0, 10, 20 , 0, 0, 20, 30, 0)/100, id =
rep(1:2, each =
4), draw = T)
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list