[R] polygon angle option perpendicular to axis
Simon, Heather
Simon.Heather at epa.gov
Thu Apr 28 14:45:07 CEST 2016
Thanks for the question. Here is a sample of the code for my plot:
Top = c(34, 39, 42, 45, 46, 41, 41, 40, 43, 38, 33, 33)
Bottom = c(24, 29, 32, 36, 32, 34, 32,41, 40, 39, 29, 24)
plot(1,1, col = "white", xlim = c(1.3,11.7), ylim = c(0,80), axis = FALSE, xaxt = "n")
axis(1, at = c(1:12))
polygon(c(c(1:12),c(12:1)), c(top, bottom), col = adjustcolor("#33a02c",alpha.f = 0.7) ,border = "#33a02c", lty = 4, density = 80, angle = 180)
I would like the hatched lines to all go in the same direction (parallel to the x-axis) so that I can layer another polygon on top with perpendicular hatches and you will be able to differentiate between the two.
-----Original Message-----
From: Peter Alspach [mailto:Peter.Alspach at plantandfood.co.nz]
Sent: Thursday, April 28, 2016 12:11 AM
To: Simon, Heather <Simon.Heather at epa.gov>; r-help at r-project.org
Subject: RE: polygon angle option perpendicular to axis
Tena koe Simon
plot(1:10, 1:10, type='n')
polygon(c(2,3,6,8), c(2,5,5,3), density=20, angle=90) polygon(c(2,3,6,8), 5+c(2,5,5,3), density=20, angle=0)
I don't understand your problem. Perhaps if you "provide[d] commented, minimal, self-contained, reproducible code" it would help.
HTH ....
Peter Alspach
-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Simon, Heather
Sent: Thursday, 28 April 2016 8:17 a.m.
To: r-help at r-project.org
Subject: [R] polygon angle option perpendicular to axis
I am trying to use the angle option in polygon to create polygons filled with horizontal and vertical lines. The polygons I am crating are irregular and it the angle function appears to set the angle of the shading perpendicular to the polygon sides rather than perpendicular to the axes. Is there any way to set the angle relative to the axes rather than relative to the polygon sides?
[[alternative HTML version deleted]]
______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
The contents of this e-mail are confidential and may be ...{{dropped:9}}
More information about the R-help
mailing list