I'm a bit blind today. I read df as a dput() . John Kane Kingston ON Canada -----Original Message----- From: hyiltiz at gmail.com Sent: Thu, 12 Feb 2015 23:38:01 +0800 To: jrkrideau at inbox.com Subject: Re: [R] ggplot2 shifting bars to only overlap in groups You are most likely simply not running the whole lines of code: note that the first line is: N = 32 Best ? =======================He who is worthy to receive his days and nights is worthy to receive* all else* from you (and me). ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? The Prophet, Gibran Kahlil On Thu, Feb 12, 2015 at 11:31 PM, John Kane <jrkrideau at inbox.com> wrote: I am gettting the error" Error in rep_len(rep.int [http://rep.int](seq_len(n), rep.int [http://rep.int](k, n)), length) : ? object 'N' not found Also your image did not come through.? Try sending it as a pdf file. when I try to create df<- data.frame(gender=gl(2,1,N, c("male","female")), ? ? ? ? ? direction=gl(2,2,N, c("up","down")), ? ? ? ? ? condition=gl(4,4,N, c("c1","c2","c3","c4")), ? ? ? ? ? location=gl(2,16,N, c("east","west")), ? ? ? ? ? t=rnorm(N, 1, 0.5), ? ? ? ? ? ci=abs(rnorm(N, 0, 0.2))) John Kane Kingston ON Canada > -----Original Message----- > From: hyiltiz at gmail.com > Sent: Thu, 12 Feb 2015 22:08:36 +0800 > To: r-help at r-project.org > Subject: [R] ggplot2 shifting bars to only overlap in groups > > Hi all, > > I have four factors for a continuous time variable along with its > confidence interval. I would like to produce a publication quality error > bar chart that is clear to understand. For now, I used colors, x axis > position, facets and alpha level to distinguish them. > > I would like to overlap each pairs of bars with the same color a bit as a > group, but not overlap each and every bars with each other. > > Here is a minimal example: > > N = 32 > df<- data.frame(gender=gl(2,1,N, c("male","female")), >? ? ? ? ? ?direction=gl(2,2,N, c("up","down")), >? ? ? ? ? ?condition=gl(4,4,N, c("c1","c2","c3","c4")), >? ? ? ? ? ?location=gl(2,16,N, c("east","west")), >? ? ? ? ? ?t=rnorm(N, 1, 0.5), >? ? ? ? ? ?ci=abs(rnorm(N, 0, 0.2))) > pp <- >? ?ggplot(df, aes(x=gender, y=t, fill=condition, alpha=direction)) + >? ?facet_grid(location~.) + >? ?geom_bar(position=position_dodge(.9), stat="identity", color="black") + >? ?geom_errorbar(aes(ymin=t-ci, ymax=t+ci), >? ? ? ? ? ? ? ? ?width=.2,? ? ? ? ? ? ? ? ? ? # Width of the error bars >? ? ? ? ? ? ? ? ?position=position_dodge(.9)) + >? ?scale_alpha_discrete(range= c(0.4, 1)) > pp > > > > In the attachment, I have added the output figure, while manually editing > the SVG file to make the lower-left group of bars to make them as I > wanted. > (The spacing in between each pair is not necessarily required.) > > > Best > ? > ======================= > He who is worthy to receive his days and nights is worthy to receive* all > else* from you (and me). >? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? The Prophet, Gibran > Kahlil> ______________________________________________> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help [https://stat.ethz.ch/mailman/listinfo/r-help] > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html [http://www.R-project.org/posting-guide.html] > and provide commented, minimal, self-contained, reproducible code. ____________________________________________________________ Can't remember your password? Do you need a strong and secure password? Use Password manager! It stores your passwords & protects your account. Check it out at http://mysecurelogon.com/password-manager [http://mysecurelogon.com/password-manager] ____________________________________________________________ FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family! Visit http://www.inbox.com/photosharing to find out more!
Hörmetjan Yiltiz
2015-Feb-12 18:28 UTC
[R] ggplot2 shifting bars to only overlap in groups
I did not know the SVG file did not come through. I thought SVG should be able to pass through the filter. Here is a PDF file along with an PNG. Guess one of them should be able to pass. ??? =======================He who is worthy to receive his days and nights is worthy to receive* all else* from you (and me). The Prophet, Gibran Kahlil On Fri, Feb 13, 2015 at 12:04 AM, John Kane <jrkrideau at inbox.com> wrote:> > I'm a bit blind today. I read df as a dput() . > > John Kane > Kingston ON Canada > > -----Original Message----- > From: hyiltiz at gmail.com > Sent: Thu, 12 Feb 2015 23:38:01 +0800 > To: jrkrideau at inbox.com > Subject: Re: [R] ggplot2 shifting bars to only overlap in groups > > You are most likely simply not running the whole lines of code: note that > the first line is: > > N = 32 > > Best > ? > =======================> He who is worthy to receive his days and nights is worthy to receive* all > else* from you (and me). > The Prophet, Gibran Kahlil > > On Thu, Feb 12, 2015 at 11:31 PM, John Kane <jrkrideau at inbox.com> wrote: > > I am gettting the error" > Error in rep_len(rep.int [http://rep.int](seq_len(n), rep.int [ > http://rep.int](k, n)), length) : > object 'N' not found > > Also your image did not come through. Try sending it as a pdf file. > > when I try to create > df<- data.frame(gender=gl(2,1,N, c("male","female")), > direction=gl(2,2,N, c("up","down")), > condition=gl(4,4,N, c("c1","c2","c3","c4")), > location=gl(2,16,N, c("east","west")), > t=rnorm(N, 1, 0.5), > ci=abs(rnorm(N, 0, 0.2))) > > John Kane > Kingston ON Canada > > > -----Original Message----- > > From: hyiltiz at gmail.com > > Sent: Thu, 12 Feb 2015 22:08:36 +0800 > > To: r-help at r-project.org > > Subject: [R] ggplot2 shifting bars to only overlap in groups > > > > Hi all, > > > > I have four factors for a continuous time variable along with its > > confidence interval. I would like to produce a publication quality error > > bar chart that is clear to understand. For now, I used colors, x axis > > position, facets and alpha level to distinguish them. > > > > I would like to overlap each pairs of bars with the same color a bit as > a > > group, but not overlap each and every bars with each other. > > > > Here is a minimal example: > > > > N = 32 > > df<- data.frame(gender=gl(2,1,N, c("male","female")), > > direction=gl(2,2,N, c("up","down")), > > condition=gl(4,4,N, c("c1","c2","c3","c4")), > > location=gl(2,16,N, c("east","west")), > > t=rnorm(N, 1, 0.5), > > ci=abs(rnorm(N, 0, 0.2))) > > pp <- > > ggplot(df, aes(x=gender, y=t, fill=condition, alpha=direction)) + > > facet_grid(location~.) + > > geom_bar(position=position_dodge(.9), stat="identity", color="black") > + > > geom_errorbar(aes(ymin=t-ci, ymax=t+ci), > > width=.2, # Width of the error bars > > position=position_dodge(.9)) + > > scale_alpha_discrete(range= c(0.4, 1)) > > pp > > > > > > > > In the attachment, I have added the output figure, while manually > editing > > the SVG file to make the lower-left group of bars to make them as I > > wanted. > > (The spacing in between each pair is not necessarily required.) > > > > > > Best > > ? > > =======================> > He who is worthy to receive his days and nights is worthy to receive* > all > > else* from you (and me). > > The Prophet, Gibran > > Kahlil > > > ______________________________________________ > > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help [ > https://stat.ethz.ch/mailman/listinfo/r-help] > > PLEASE do read the posting guide > > http://www.R-project.org/posting-guide.html [ > http://www.R-project.org/posting-guide.html] > > and provide commented, minimal, self-contained, reproducible code. > > ____________________________________________________________ > Can't remember your password? Do you need a strong and secure password? > Use Password manager! It stores your passwords & protects your account. > Check it out at http://mysecurelogon.com/password-manager [ > http://mysecurelogon.com/password-manager] > > ____________________________________________________________ > FREE ONLINE PHOTOSHARING - Share your photos online with your friends and > family! > Visit http://www.inbox.com/photosharing to find out more! > > >-------------- next part -------------- A non-text attachment was scrubbed... Name: DodgeInGroup.pdf Type: application/pdf Size: 27457 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20150213/9eecf0a8/attachment.pdf> -------------- next part -------------- A non-text attachment was scrubbed... Name: DodgeInGroup.png Type: image/png Size: 31062 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20150213/9eecf0a8/attachment.png>