[R] (no subject)

William Dunlap wdunlap at tibco.com
Sat Dec 1 01:54:39 CET 2012


>> subplot(pie(sec,col=color1,labels=" ",radius=0.05,border=NA,cex=0.8), x-3,y=15)

Did you mean x=3 instead of x-3?

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -----Original Message-----
> From: bibek sharma [mailto:mbhpathak at gmail.com]
> Sent: Friday, November 30, 2012 4:48 PM
> To: William Dunlap
> Subject: Re: [R] (no subject)
> 
> Hello Bill,
> Your code works perfectly and got a nice plot. No problem there.
> But I wanted to center the pie diagram obtained from
> 
> cars <- c(1,1,1,1,1,1,1,1)
> color1 <- c("grey80","grey80","grey80","grey80","gray80","grey30","grey20","gray10")
> pie(cars,col=color1,labels=" ",radius=0.05,border=NA,cex=0.8))
> 
> Some how it did not work.
> 
> Here is what I tried,
> 
> library(visualFields)
> library(car)
> a<-saplocmap$p24d2
> ordinate<-data.frame(a$xod,a$yod)
> ordinate
> plot( a$xod,a$yod, xlim=c(-30,30),
> ylim=c(-30,30),xlab="",ylab="",type="p", data=ordinate)
> abline(h=0,v=0)
> 
> subplot(pie(1:8),x=-3,y=21,size=c(0.5,0.5))
> subplot(pie(1:8),x=3,y=21,size=c(0.5,0.5))
> subplot(pie(1:8),x=9,y=21,size=c(0.5,0.5))
> subplot(pie(1:8),x=15,y=-15,size=c(0.5,0.5))
> subplot(pie(1:8),x=-3,y=15, size=c(0.5,0.5))
> subplot(pie(1:8),x=-9,y=15,size=c(0.5,0.5))
> subplot(pie(1:8),x=9,y=-21,size=c(0.5,0.5))
> subplot(pie(1:8),x=3,y=-21,size=c(0.5,0.5))
> 
> 
> Below code did not put the pic diagram on the location specified
> 
> a<-saplocmap$p24d2
> ordinate<-data.frame(a$xod,a$yod)
> ordinate
> plot( a$xod,a$yod, xlim=c(-30,30),
> ylim=c(-30,30),xlab="",ylab="",type="p", data=ordinate)
> abline(h=0,v=0)
> ## par(new=TRUE)
> sec <- c(1,1,1,1,1,1,1,1)
> color1 <- c("grey80","grey80","grey80","grey80","gray80","grey30","grey20","gray10"
> )
> ##pie(sec,col=color1,labels=" ",radius=0.05,border=NA,cex=0.8)
> subplot(pie(sec,col=color1,labels=" ",radius=0.05,border=NA,cex=0.8), x-3,y=15)
> 
> 
> Any suggestion is much appreciated!
> Thank you in advance,
> Bibek.
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> On Fri, Nov 30, 2012 at 4:26 PM, William Dunlap <wdunlap at tibco.com> wrote:
> > Please be more specific.
> >
> > How did it not work?  Did my example not work?  Was there an
> > error message or the wrong picture?  Did you install and load
> > the TeachingDemo's package so subplot() was in scope?  Did
> > the pie chart drawn by subplot() look different (aside its placement
> > and size) from the one you originally got?
> >
> > Also, continue the cc to R-help at r-project.org so others can contribute
> > or learn something.
> >
> > Bill Dunlap
> > Spotfire, TIBCO Software
> > wdunlap tibco.com
> >
> >
> >> -----Original Message-----
> >> From: bibek sharma [mailto:mbhpathak at gmail.com]
> >> Sent: Friday, November 30, 2012 3:37 PM
> >> To: William Dunlap
> >> Subject: Re: [R] (no subject)
> >>
> >> Thank you Bill.
> >> I want pie of equal sector. I tried your code but did not work.dont know why?
> >> Any suggestion?
> >>
> >>
> >> library(visualFields)
> >> library(car)
> >> a<-saplocmap$p24d2
> >> ordinate<-data.frame(a$xod,a$yod)
> >> ordinate
> >> plot( a$xod,a$yod, xlim=c(-30,30),
> >> ylim=c(-30,30),xlab="",ylab="",type="p", data=ordinate)
> >> abline(h=0,v=0)
> >>  bcars <- c(1,1,1,1,1,1,1,1)
> >> color1 <-
> c("grey80","grey80","grey80","grey80","gray80","grey30","grey20","gray10"
> >> )
> >> subplot(pie(cars,col=color1,labels=" ",radius=0.05,border=NA,cex=0.8),x=3,y=15)
> >>
> >>
> >>
> >>
> >> On Fri, Nov 30, 2012 at 2:26 PM, William Dunlap <wdunlap at tibco.com> wrote:
> >> > Try subplot() from the TeachingDemos package.  E.g.,
> >> >
> >> >   > plot(c(1,2,3), c(1,3,2), xlim=c(0,5), ylim=c(0,10))
> >> >   > subplot(pie(1:5), x=4, y=6)
> >> >   > abline(h=6, v=4)
> >> >   > subplot(pie(1:5), x=1, y=8, size=c(0.5, 0.5))
> >> >
> >> > Bill Dunlap
> >> > Spotfire, TIBCO Software
> >> > wdunlap tibco.com
> >> >
> >> >
> >> >> -----Original Message-----
> >> >> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
> >> Behalf
> >> >> Of bibek sharma
> >> >> Sent: Friday, November 30, 2012 2:07 PM
> >> >> To: R help
> >> >> Subject: [R] (no subject)
> >> >>
> >> >> Hello R usuer,
> >> >>
> >> >> The code given below superimposes a pie diagram on another plot
> >> >> containing some points. However, I would like to center the pie
> >> >> diagram on the xy location on the plot, but not on the center. is
> >> >> there any way to re-center pic diagram.
> >> >> Any suggestion or better alternative are highly appreciated.
> >> >> Thank you in advance for your help.
> >> >>
> >> >> Regards,
> >> >> Bibke
> >> >>
> >> >> library(visualFields)
> >> >> library(car)
> >> >> a<-saplocmap$p24d2
> >> >> ordinate<-data.frame(a$xod,a$yod)
> >> >> plot( a$xod,a$yod, xlim=c(-30,30),
> >> >> ylim=c(-30,30),xlab="",ylab="",type="p", data=ordinate)
> >> >> abline(v=0,h=0)
> >> >> par(new=TRUE)
> >> >>
> >> >> # Define cars vector with 8 values
> >> >> cars <- c(1,1,1,1,1,1,1,1)
> >> >>
> >> >> # Define colors in each sector
> >> >>
> >> >> color1 <-
> >> c("grey80","grey80","grey80","grey80","gray80","grey30","grey20","gray10"
> >> >> ) ## gray10=<0.0001, gray20<0.001, gray30<0.01, gray40=<0.05, gray
> >> >> 80=>0.05
> >> >> # Putting sector levels
> >> >> car_labels <- c(1,2,3,4,5,6,7,8)
> >> >> car_labels <- paste(car_labels,sep="")
> >> >>
> >> >> # Create a pie chart with defined heading and custom colors
> >> >> # and labels
> >> >>
> >> >> pie(cars, main="Sectors", col=color1, labels=" ",
> >> >> radius=0.05,border=NA, cex=0.8)
> >> >>
> >> >> ______________________________________________
> >> >> R-help at 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.




More information about the R-help mailing list