[R] polygon angle option perpendicular to axis
Simon.Heather at epa.gov
Thu Apr 28 18:32:43 CEST 2016
Thanks, adding asp = 1 did the trick!
From: David L Carlson [mailto:dcarlson at tamu.edu]
Sent: Thursday, April 28, 2016 12:17 PM
To: Greg Snow <538280 at gmail.com>; Simon, Heather <Simon.Heather at epa.gov>
Cc: r-help at r-project.org
Subject: RE: [R] polygon angle option perpendicular to axis
The angle is not based on the polygon edges, but it can seem that way if you do not use the asp=1 argument in your plot. Try this example,
> plot(1:10, 1:10, type='n')
> x <- c(1, 3, 5, 3)
> y <- c(3, 5, 3, 1)
> polygon(x, y, angle=0, density=10)
> polygon(x, y + 4.5, angle=45, density=10) polygon(x + 4.5, y + 4.5,
> angle=90, density=10) polygon(x + 4.5, y, angle=135, density=10)
Notice that the 45 and 135 degree lines (upper left and lower right) do not seem to be parallel to the edges of the boxes which should be 45 and 135. Run the code again adding asp=1 to the plot() function and now the lines are parallel.
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Greg Snow
Sent: Thursday, April 28, 2016 9:50 AM
To: Simon, Heather
Cc: r-help at r-project.org
Subject: Re: [R] polygon angle option perpendicular to axis
Filling polygons with lines is a throwback to the time when the height of quality graphics was the mechanical pen plotter (a device that used a pen in a mechanical arm to draw the plot on a piece of paper).
Computing and printing technology has advanced quite a bit from that day, so you may want to reconsider why you want polygons filled with lines instead of just a solid color (and I consider white, grey, and black as colors for this purpose).
On Wed, Apr 27, 2016 at 2:17 PM, Simon, Heather <Simon.Heather at epa.gov> wrote:
> 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
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
Gregory (Greg) L. Snow Ph.D.
538280 at gmail.com
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.
More information about the R-help