Rotating points, preferably in grid

4 messages
Open this post in threaded view
|

Rotating points, preferably in grid

 I want to make a plot in polar coordinates. I want to use pch with shapes that do not have radial symmetry, so I want to rotate them such that they face inwards. I am using grid for my plotting, but I provide motivating examples in graphics. The following plot almost gets me what I want.   theta <- 2*pi*seq(0,7/8,1/8)   plot(cos(theta), sin(theta), pch=2, axes=F, asp=1) But I want the points to face inwards. I can do something like this with text, but I can set only a constant rotation   plot.new()   plot.window(c(-1,1),c(-1,1), asp=1)   text(cos(theta), sin(theta), 'Tom', srt  =runif(1,0,360)) To rotate all of the points, I can do something like this.   plot.new()   plot.window(c(-1,1),c(-1,1), asp=1)   for (the.theta in theta)     text(cos(the.theta), sin(the.theta), 'Tom',          srt=(360/(2*pi))*(the.theta-(1/4)*2*pi)) So perhaps I could use a "T" instead of a numeric pch and consequently do something like this.   plot.new()   plot.window(c(-1,1),c(-1,1), asp=1)   for (the.theta in theta)     text(cos(the.theta), sin(the.theta), 'T',          srt=(360/(2*pi))*(the.theta+(1/4)*2*pi)) But that seems a bit silly. Is there a more declarative way of doing this, preferably in grid? Thanks ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

Re: Rotating points, preferably in grid

 Silly? Not really. It's simple. It works. You could jump into unicode for your text and make it look nicer, e.g., using '\u2191' or some other shape in place of 'T' http://unicode.org/charts/http://unicode.org/charts/PDF/U2190.pdf-Dan On Wed, Aug 24, 2016 at 7:16 PM, Thomas Levine <[hidden email]> wrote: > I want to make a plot in polar coordinates. I want to use pch with > shapes that do not have radial symmetry, so I want to rotate them such > that they face inwards. I am using grid for my plotting, but I provide > motivating examples in graphics. > > The following plot almost gets me what I want. > >   theta <- 2*pi*seq(0,7/8,1/8) >   plot(cos(theta), sin(theta), pch=2, axes=F, asp=1) > > But I want the points to face inwards. I can do something like this with > text, but I can set only a constant rotation > >   plot.new() >   plot.window(c(-1,1),c(-1,1), asp=1) >   text(cos(theta), sin(theta), 'Tom', srt >  =runif(1,0,360)) > > To rotate all of the points, I can do something like this. > >   plot.new() >   plot.window(c(-1,1),c(-1,1), asp=1) >   for (the.theta in theta) >     text(cos(the.theta), sin(the.theta), 'Tom', >          srt=(360/(2*pi))*(the.theta-(1/4)*2*pi)) > > So perhaps I could use a "T" instead of a numeric pch and consequently > do something like this. > >   plot.new() >   plot.window(c(-1,1),c(-1,1), asp=1) >   for (the.theta in theta) >     text(cos(the.theta), sin(the.theta), 'T', >          srt=(360/(2*pi))*(the.theta+(1/4)*2*pi)) > > But that seems a bit silly. > > Is there a more declarative way of doing this, preferably in grid? > > Thanks > > ______________________________________________ > [hidden email] 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. > > -- Dan Dalthorp, PhD USGS Forest and Rangeland Ecosystem Science Center Forest Sciences Lab, Rm 189 3200 SW Jefferson Way Corvallis, OR 97331 ph: 541-750-0953 [hidden email]         [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.