Re: [R] plot points using circles filled half in red and half in blue.
On 03/28/2012 01:49 PM, alan wrote: I want to plot many points and want to use circles. The filling color depends on variable a. if a=1, then not fill if a=2 then fill with red, if a=3 then fill with blue, if a=4, fill half with red and half with blue. Can anyone tell me how to plot the case a=4? Thanks a lot Hi alan, I think you can do this with the floating.pie function (plotrix). Just plot two equal numbers and the pie will be two half circles. 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] plot points using circles filled half in red and half in blue.
On 28/03/12 15:49, alan wrote: I want to plot many points and want to use circles. The filling color depends on variable a. if a=1, then not fill if a=2 then fill with red, if a=3 then fill with blue, if a=4, fill half with red and half with blue. Can anyone tell me how to plot the case a=4? Thanks a lot I could be wrong --- this was known to happen once :-) --- but I strongly doubt that there is anything ``off the peg'' that will do what you want. You'll have to roll your own. I'd suggest looking at the draw.circle() function from the plotrix package for some ideas on how to get started. It seems to me that for each such circle you'll have to plot two polygons --- one for each half of the circle --- and specify fill=red for one and fill=blue for the other. It's all do-able, but is it worth the effort? Why not fill with green (say) when a=4? cheers, Rolf Turner __ 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] plot points using circles filled half in red and half in blue.
Hi Alan, on an UTF-8 locale you can use \u25D6 and \u25D7, but you have to plot group a=4 twice. On Windows in a non-utf locale you can use a special Windows font: windowsFonts(wdg2=windowsFont(Wingdings 2)) plot(0:1,0:1) strh-strheight(x)/2.02 points(x = 0.5, y = 0.75+strh/2,pch=¼,family=wdg2,col=red) points(x = 0.5, y = 0.75-strh/2,pch=½,family=wdg2,col=green) strw-strwidth(º) points(.4-strw/2,.7,pch=º,family=wdg2,col=red) points(.4+strw/2,.7,pch=»,family=wdg2,col=green) Cheers Am 28.03.2012 04:49, schrieb alan: I want to plot many points and want to use circles. The filling color depends on variable a. if a=1, then not fill if a=2 then fill with red, if a=3 then fill with blue, if a=4, fill half with red and half with blue. Can anyone tell me how to plot the case a=4? Thanks a lot __ 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. -- Eik Vettorazzi Department of Medical Biometry and Epidemiology University Medical Center Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/7410-58243 F ++49/40/7410-57790 -- Pflichtangaben gemäß Gesetz über elektronische Handelsregister und Genossenschaftsregister sowie das Unternehmensregister (EHUG): Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; Gerichtsstand: Hamburg Vorstandsmitglieder: Prof. Dr. Guido Sauter (Vertreter des Vorsitzenden), Dr. Alexander Kirstein, Joachim Prölß, Prof. Dr. Dr. Uwe Koch-Gromus __ 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] plot points using circles filled half in red and half in blue.
On Wed, Mar 28, 2012 at 11:02 AM, Eik Vettorazzi e.vettora...@uke.de wrote: Hi Alan, on an UTF-8 locale you can use \u25D6 and \u25D7, but you have to plot group a=4 twice. The problem with that is that by default the two half-circles will be centred on the point location, so won't join look like a whole circle. I'm not sure how you can adjust the point precisely to make the two symbols line up. If you use another of the unicode symbols with the text() plotting function you can do it. The symbols are half-coloured, half transparent so you can overlay them thus: plot(1:10,type=n) text(1:10,1:10,\u25D0,col=red,cex=4) text(1:10,1:10,\u25D0,col=blue,srt=180,cex=4) the only problem is then a slight outline of the second colour. I tried to fix that by overplotting a unicode circle (25EF) but that is slightly larger than the other circles. Your font may vary -- blog: http://geospaced.blogspot.com/ web: http://www.maths.lancs.ac.uk/~rowlings web: http://www.rowlingson.com/ twitter: http://twitter.com/geospacedman pics: http://www.flickr.com/photos/spacedman __ 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] plot points using circles filled half in red and half in blue.
On Tue, Mar 27, 2012 at 10:49 PM, alan alan.wu2...@gmail.com wrote: I want to plot many points and want to use circles. The filling color depends on variable a. if a=1, then not fill if a=2 then fill with red, if a=3 then fill with blue, if a=4, fill half with red and half with blue. Can anyone tell me how to plot the case a=4? Thanks a lot There is an example in the vignette that comes with the gridBase package of having a pie chart for each point. -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ 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] plot points using circles filled half in red and half in blue.
I would use the my.symbols function from the TeachingDemos package (but then I might be a little bit biased), here is a simple example: library(TeachingDemos) x - runif(25) y - runif(25) z - sample(1:4, 25, TRUE) ms.halfcirc2 - function(col, adj=pi/2, ...) { theta - seq(0, 2*pi, length.out=300)+adj x - cos(theta) y - sin(theta) if(col==1) { polygon(x,y) } else if(col==2) { polygon(x,y, col='red') } else if(col==3) { polygon(x,y, col='blue') } else { polygon(x[1:150], y[1:150], border=NA, col='red') polygon(x[151:300], y[151:300], border=NA, col='blue') polygon(x,y) } } my.symbols( x, y, ms.halfcirc2, inches=1/5, add=FALSE, symb.plots=TRUE, col=z) # spice it up a bit my.symbols( x, y, ms.halfcirc2, inches=1/5, add=FALSE, symb.plots=TRUE, col=z, adj=runif(25, 0, pi)) Adjust things to fit better what you want. On Tue, Mar 27, 2012 at 8:49 PM, alan alan.wu2...@gmail.com wrote: I want to plot many points and want to use circles. The filling color depends on variable a. if a=1, then not fill if a=2 then fill with red, if a=3 then fill with blue, if a=4, fill half with red and half with blue. Can anyone tell me how to plot the case a=4? Thanks a lot __ 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. -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com __ 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.