Re: [R] Plotting problems directional or rose plots
On 08/02/2011 01:38 AM, kitty wrote: Hi again, I have tried playing around with the code given to me by Alan and Jim, thank you for the code but unfortunatelyI can't seem to get either of them to work... Alans does not work with the sample data and Jims is giving the error : Error in radial.grid(labels = labels, label.pos = label.pos, radlab = radlab, : could not find function boxed.labels I have also tried Rose plots in the (heR.Misc) library to to avail. Sorry, does anyone know how to get the plots I need? Hi kitty, Oops, I forgot that the code calls boxed.labels, a function in the plotrix package. Install that and it should work. Jim __ R-help@r-project.org mailing list 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.
Re: [R] Plotting problems directional or rose plots
Hi again, I have tried playing around with the code given to me by Alan and Jim, thank you for the code but unfortunatelyI can't seem to get either of them to work... Alans does not work with the sample data and Jims is giving the error : Error in radial.grid(labels = labels, label.pos = label.pos, radlab = radlab, : could not find function boxed.labels I have also tried Rose plots in the (heR.Misc) library to to avail. Sorry, does anyone know how to get the plots I need? Thank you all for reading this and for your help k. On Tue, Jul 26, 2011 at 10:20 PM, kitty kitty.a1...@gmail.com wrote: Hi, I'm trying to get a plot that looks somewhat like the attached image (sketched in word). I think I need somthing called a rose diagram? but I can't get it to do what I want. I'm happy to use any library. Essentially, I want a circle with degree slices every 10 degrees with 0 at the top representing north, and 'tick marks' around the outside in 10 degree increments to match the slices (so the slices need to be ofset by 5 degrees so the 0 degree slice actually faces north) I then want to be able to colour in the slices depending on the distance that the factor extends to; so for example the 9000 dist is the largest in the example so should fill the slice, a distance in this plot of 4500 would fill halfway up the slice. I also want to be able to specify the colour of each slice so that I can relate it back to the spatial correlograms I have. I have added some sample data below. Thank you for reading my post, All help is greatly appreciated, K sample data: #distance factor extends to dist-c(5000,7000,9000,4500,6000,500) #direction angle-c(0,10,20,30,40,50) #list of desired colour example, order corrisponds to associated angle/direction color.list-c('red','blue','green','yellow','pink','black') (my real data is from 0 to 350 degrees, and so I have corresponding distance and colour data for each 10 degree increment). [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
Re: [R] Plotting problems directional or rose plots
Searching R Graphical Manual (http://www.oga-lab.net/RGM2/, mirror http://www.oga-lab.net/RGM2/) shows possible candidates in packages circular (windrose), IDPmisc (plot.rose), climatol (rosavent), openair (windRose), and oce (as.windrose). -- David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77843-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of kitty Sent: Monday, August 01, 2011 10:39 AM To: r-help@r-project.org Subject: Re: [R] Plotting problems directional or rose plots Hi again, I have tried playing around with the code given to me by Alan and Jim, thank you for the code but unfortunatelyI can't seem to get either of them to work... Alans does not work with the sample data and Jims is giving the error : Error in radial.grid(labels = labels, label.pos = label.pos, radlab = radlab, : could not find function boxed.labels I have also tried Rose plots in the (heR.Misc) library to to avail. Sorry, does anyone know how to get the plots I need? Thank you all for reading this and for your help k. On Tue, Jul 26, 2011 at 10:20 PM, kitty kitty.a1...@gmail.com wrote: Hi, I'm trying to get a plot that looks somewhat like the attached image (sketched in word). I think I need somthing called a rose diagram? but I can't get it to do what I want. I'm happy to use any library. Essentially, I want a circle with degree slices every 10 degrees with 0 at the top representing north, and 'tick marks' around the outside in 10 degree increments to match the slices (so the slices need to be ofset by 5 degrees so the 0 degree slice actually faces north) I then want to be able to colour in the slices depending on the distance that the factor extends to; so for example the 9000 dist is the largest in the example so should fill the slice, a distance in this plot of 4500 would fill halfway up the slice. I also want to be able to specify the colour of each slice so that I can relate it back to the spatial correlograms I have. I have added some sample data below. Thank you for reading my post, All help is greatly appreciated, K sample data: #distance factor extends to dist-c(5000,7000,9000,4500,6000,500) #direction angle-c(0,10,20,30,40,50) #list of desired colour example, order corrisponds to associated angle/direction color.list-c('red','blue','green','yellow','pink','black') (my real data is from 0 to 350 degrees, and so I have corresponding distance and colour data for each 10 degree increment). [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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. __ R-help@r-project.org mailing list 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.
Re: [R] Plotting problems directional or rose plots
I'm not sure if there are any packages that do this, but I've created similar plots in R. The easiest way I've found is to think in terms of a unit circle in polar coordinates for drawing the plot. I haven't tested the code below, but it will give you the idea. dist=dist/9000 t = seq(0,360,length.out=1000)*pi/180 #want radians not degrees angle=angle*pi/180 circle$x=cos(t) circle$y=sin(t) plot(circle$x,circle$y,type='l') You can use the polygon function to draw the 'petals'. # for 0-10 t0 = seq(0,10,length.out=50)*pi/180 petal0$x = dist[1]*cos(t0) petal0$y = dist[1]*sin(t0) polygon( x=c(0,petal0$x,0),y=c(0,petal0$y,0),col=color.list[1]) I hope this helps. Alan Mitchell -Original Message- From: kitty [mailto:kitty.a1...@gmail.com] Sent: Tue 7/26/2011 2:20 PM To: r-help@r-project.org Subject: [R] Plotting problems directional or rose plots Hi, I'm trying to get a plot that looks somewhat like the attached image (sketched in word). I think I need somthing called a rose diagram? but I can't get it to do what I want. I'm happy to use any library. Essentially, I want a circle with degree slices every 10 degrees with 0 at the top representing north, and 'tick marks' around the outside in 10 degree increments to match the slices (so the slices need to be ofset by 5 degrees so the 0 degree slice actually faces north) I then want to be able to colour in the slices depending on the distance that the factor extends to; so for example the 9000 dist is the largest in the example so should fill the slice, a distance in this plot of 4500 would fill halfway up the slice. I also want to be able to specify the colour of each slice so that I can relate it back to the spatial correlograms I have. I have added some sample data below. Thank you for reading my post, All help is greatly appreciated, K sample data: #distance factor extends to dist-c(5000,7000,9000,4500,6000,500) #direction angle-c(0,10,20,30,40,50) #list of desired colour example, order corrisponds to associated angle/direction color.list-c('red','blue','green','yellow','pink','black') (my real data is from 0 to 350 degrees, and so I have corresponding distance and colour data for each 10 degree increment). __ R-help@r-project.org mailing list 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.
Re: [R] Plotting problems directional or rose plots
I ran the code I sent earlier and there were a few bugs. That's what I get for using my phone to write code. This works a little better. #direction angle-seq(0,350,10) #distance factor extends to dist = sample.int(9000,size=length(angle)) #list of colors, order corrisponds to associated angle/direction #color.list-c('red','blue','green','yellow','pink','black') color.list=cm.colors(9000)[dist] # Plot Code dist = dist/9000 t = seq(0,360,length.out=1000)*pi/180 #want radians not degrees circle = data.frame(x=cos(t),y=sin(t)) par(mar=c(0,0,0,0)) plot(circle$x,circle$y,type='l') for(idx in 1:length(dist)){ t0 = seq(angle[idx],angle[idx]+10,length.out=50)*pi/180 petal0 = data.frame(x = dist[idx]*cos(t0),y = dist[idx]*sin(t0)) polygon( x=c(0,petal0$x,0),y=c(0,petal0$y,0),col=color.list[idx]) } Alan Mitchell al...@crab.org -Original Message- From: alanm (Alan Mitchell) Sent: Wednesday, July 27, 2011 7:04 AM To: kitty; r-help@r-project.org Subject: RE: [R] Plotting problems directional or rose plots I'm not sure if there are any packages that do this, but I've created similar plots in R. The easiest way I've found is to think in terms of a unit circle in polar coordinates for drawing the plot. I haven't tested the code below, but it will give you the idea. dist=dist/9000 t = seq(0,360,length.out=1000)*pi/180 #want radians not degrees angle=angle*pi/180 circle$x=cos(t) circle$y=sin(t) plot(circle$x,circle$y,type='l') You can use the polygon function to draw the 'petals'. # for 0-10 t0 = seq(0,10,length.out=50)*pi/180 petal0$x = dist[1]*cos(t0) petal0$y = dist[1]*sin(t0) polygon( x=c(0,petal0$x,0),y=c(0,petal0$y,0),col=color.list[1]) I hope this helps. Alan Mitchell -Original Message- From: kitty [mailto:kitty.a1...@gmail.com] Sent: Tue 7/26/2011 2:20 PM To: r-help@r-project.org Subject: [R] Plotting problems directional or rose plots Hi, I'm trying to get a plot that looks somewhat like the attached image (sketched in word). I think I need somthing called a rose diagram? but I can't get it to do what I want. I'm happy to use any library. Essentially, I want a circle with degree slices every 10 degrees with 0 at the top representing north, and 'tick marks' around the outside in 10 degree increments to match the slices (so the slices need to be ofset by 5 degrees so the 0 degree slice actually faces north) I then want to be able to colour in the slices depending on the distance that the factor extends to; so for example the 9000 dist is the largest in the example so should fill the slice, a distance in this plot of 4500 would fill halfway up the slice. I also want to be able to specify the colour of each slice so that I can relate it back to the spatial correlograms I have. I have added some sample data below. Thank you for reading my post, All help is greatly appreciated, K sample data: #distance factor extends to dist-c(5000,7000,9000,4500,6000,500) #direction angle-c(0,10,20,30,40,50) #list of desired colour example, order corrisponds to associated angle/direction color.list-c('red','blue','green','yellow','pink','black') (my real data is from 0 to 350 degrees, and so I have corresponding distance and colour data for each 10 degree increment). __ R-help@r-project.org mailing list 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.
[R] Plotting problems directional or rose plots
Hi, I'm trying to get a plot that looks somewhat like the attached image (sketched in word). I think I need somthing called a rose diagram? but I can't get it to do what I want. I'm happy to use any library. Essentially, I want a circle with degree slices every 10 degrees with 0 at the top representing north, and 'tick marks' around the outside in 10 degree increments to match the slices (so the slices need to be ofset by 5 degrees so the 0 degree slice actually faces north) I then want to be able to colour in the slices depending on the distance that the factor extends to; so for example the 9000 dist is the largest in the example so should fill the slice, a distance in this plot of 4500 would fill halfway up the slice. I also want to be able to specify the colour of each slice so that I can relate it back to the spatial correlograms I have. I have added some sample data below. Thank you for reading my post, All help is greatly appreciated, K sample data: #distance factor extends to dist-c(5000,7000,9000,4500,6000,500) #direction angle-c(0,10,20,30,40,50) #list of desired colour example, order corrisponds to associated angle/direction color.list-c('red','blue','green','yellow','pink','black') (my real data is from 0 to 350 degrees, and so I have corresponding distance and colour data for each 10 degree increment). __ R-help@r-project.org mailing list 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.