R-users, Can someone please advise how to improve the code below that was used to produce the graph shown at the following hyperlink (https://chemistryinthecity.neocities.org/content/entry1808.html#17)? The request is to add space between the annual data groups. barplot(gceac[,3], xlab='year', ylab='percentage of each grade', col=c('aliceblue', 'aquamarine', 'blue', 'chocolate', 'darkgreen', 'firebrick', 'violet'), legend=gceac[1:7,2], args.legend = list(x = 40, y = 30, title='grades'), main='A-level grades, chemistry', beside=T, space=c(0,2), ylim=c(0,30)) years<-c(2014,2015,2016,2017,2018) mtext(years, side=1, at=c(5, 12, 19, 26, 33)) R-users, Can someone please advise how to improve the code below that was used to produce the graph shown at the following hyperlink (https://chemistryinthecity.neocities.org/content/entry1808.html#17)? The request is to add space between the annual data groups. barplot(gceac[,3], xlab='year', ylab='percentage of each grade', col=c('aliceblue', 'aquamarine', 'blue', 'chocolate', 'darkgreen', 'firebrick', 'violet'), legend=gceac[1:7,2], args.legend = list(x = 40, y = 30, title='grades'), main='A-level grades, chemistry', beside=T, space=c(0,2), ylim=c(0,30)) years<-c(2014,2015,2016,2017,2018) mtext(years, side=1, at=c(5, 12, 19, 26, 33)) [[alternative HTML version deleted]]
Using the lattice package would provide an easy way to distinguish years, by putting them in different panels. Lattice would also help avoid some other features of this graph that, in my opinion, are suboptimal. See Tufte or Cleveland. Chris Ryan -- Sent from my Android device with K-9 Mail. Please excuse my brevity. On August 17, 2018 7:55:43 AM EDT, citc at disroot.org wrote:>R-users, > >Can someone please advise how to improve the code below that was used >to produce the graph shown at the following hyperlink >(https://chemistryinthecity.neocities.org/content/entry1808.html#17)? >The request is to add space between the annual data groups. > >barplot(gceac[,3], xlab='year', ylab='percentage of each grade', >col=c('aliceblue', 'aquamarine', 'blue', 'chocolate', 'darkgreen', >'firebrick', 'violet'), legend=gceac[1:7,2], args.legend = list(x = 40, >y = 30, title='grades'), main='A-level grades, chemistry', beside=T, >space=c(0,2), ylim=c(0,30)) >years<-c(2014,2015,2016,2017,2018) >mtext(years, side=1, at=c(5, 12, 19, 26, 33)) >R-users, Can someone please advise how to improve the code below that >was used to produce the graph shown at the following hyperlink >(https://chemistryinthecity.neocities.org/content/entry1808.html#17)? >The request is to add space between the annual data groups. >barplot(gceac[,3], xlab='year', ylab='percentage of each grade', >col=c('aliceblue', 'aquamarine', 'blue', 'chocolate', 'darkgreen', >'firebrick', 'violet'), legend=gceac[1:7,2], args.legend = list(x = 40, >y = 30, title='grades'), main='A-level grades, chemistry', beside=T, >space=c(0,2), ylim=c(0,30)) years<-c(2014,2015,2016,2017,2018) >mtext(years, side=1, at=c(5, 12, 19, 26, 33)) > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at r-project.org 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.
Notice below that your message is substantially scrambled. R-Help is a plain text only list so you should set your email client to produce plain text messages. The best place to start is with the manual page for the barplot() function: ?barplot or help(barplot) You will find the description of the space= argument useful. ---------------------------------------- David L Carlson Department of Anthropology Texas A&M University College Station, TX 77843-4352 -----Original Message----- From: R-help <r-help-bounces at r-project.org> On Behalf Of citc at disroot.org Sent: Friday, August 17, 2018 6:56 AM To: r-help at r-project.org Subject: [R] bar plot add space to group data R-users, Can someone please advise how to improve the code below that was used to produce the graph shown at the following hyperlink (https://chemistryinthecity.neocities.org/content/entry1808.html#17)? The request is to add space between the annual data groups. barplot(gceac[,3], xlab='year', ylab='percentage of each grade', col=c('aliceblue', 'aquamarine', 'blue', 'chocolate', 'darkgreen', 'firebrick', 'violet'), legend=gceac[1:7,2], args.legend = list(x = 40, y = 30, title='grades'), main='A-level grades, chemistry', beside=T, space=c(0,2), ylim=c(0,30)) years<-c(2014,2015,2016,2017,2018) mtext(years, side=1, at=c(5, 12, 19, 26, 33)) R-users, Can someone please advise how to improve the code below that was used to produce the graph shown at the following hyperlink (https://chemistryinthecity.neocities.org/content/entry1808.html#17)? The request is to add space between the annual data groups. barplot(gceac[,3], xlab='year', ylab='percentage of each grade', col=c('aliceblue', 'aquamarine', 'blue', 'chocolate', 'darkgreen', 'firebrick', 'violet'), legend=gceac[1:7,2], args.legend = list(x = 40, y = 30, title='grades'), main='A-level grades, chemistry', beside=T, space=c(0,2), ylim=c(0,30)) years<-c(2014,2015,2016,2017,2018) mtext(years, side=1, at=c(5, 12, 19, 26, 33)) [[alternative HTML version deleted]] ______________________________________________ R-help at r-project.org 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.
On 18/08/18 02:37, David L Carlson wrote:> Notice below that your message is substantially scrambled. R-Help is a > plain text only list so you should set your email client to produce plain text messages. > > The best place to start is with the manual page for the barplot() function: > > ?barplot or help(barplot) > > You will find the description of the space= argument useful.<SNIP> If one struggles through the garbled html bumff, one sees that the OP *did* indeed use the "space=" argument. However it does not appear to have had the desired effect, and I cannot see why. Since the OP did not supply the data, I cannot experiment. Perhaps someone else will have some insight. cheers, Rolf Turner -- Technical Editor ANZJS Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276
Hi citc, Try this: geac<-matrix(c(9,9,8,8,8,23,23,23,23,22,27,27,27,25,24, 19,19,19,20,20,17,17,17,18,19,8,8,8,9,9,2,2,3,3,3),ncol=5,byrow=TRUE) library(plotrix) barp(geac,names.arg=2014:2018,main="A level grades chemistry", xlab="Year",ylab="Percentage of each grade",ylim=c(0,30), col=c("white","lightblue","blue","orange","green","red","pink")) Jim On Fri, Aug 17, 2018 at 9:55 PM, <citc at disroot.org> wrote:> R-users, > > Can someone please advise how to improve the code below that was used to produce the graph shown at the following hyperlink (https://chemistryinthecity.neocities.org/content/entry1808.html#17)? The request is to add space between the annual data groups. > > barplot(gceac[,3], xlab='year', ylab='percentage of each grade', col=c('aliceblue', 'aquamarine', 'blue', 'chocolate', 'darkgreen', 'firebrick', 'violet'), legend=gceac[1:7,2], args.legend = list(x = 40, y = 30, title='grades'), main='A-level grades, chemistry', beside=T, space=c(0,2), ylim=c(0,30)) > years<-c(2014,2015,2016,2017,2018) > mtext(years, side=1, at=c(5, 12, 19, 26, 33)) > R-users, Can someone please advise how to improve the code below that was used to produce the graph shown at the following hyperlink (https://chemistryinthecity.neocities.org/content/entry1808.html#17)? The request is to add space between the annual data groups. barplot(gceac[,3], xlab='year', ylab='percentage of each grade', col=c('aliceblue', 'aquamarine', 'blue', 'chocolate', 'darkgreen', 'firebrick', 'violet'), legend=gceac[1:7,2], args.legend = list(x = 40, y = 30, title='grades'), main='A-level grades, chemistry', beside=T, space=c(0,2), ylim=c(0,30)) years<-c(2014,2015,2016,2017,2018) mtext(years, side=1, at=c(5, 12, 19, 26, 33)) > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org 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.
Jim: (a) There's no legend. (b) I am still curious as to why the OP's code didn't work, in that the "space=c(0,2)" argument seemed to have no effect. cheers, Rolf On 18/08/18 20:45, Jim Lemon wrote:> Hi citc, > Try this: > > geac<-matrix(c(9,9,8,8,8,23,23,23,23,22,27,27,27,25,24, > 19,19,19,20,20,17,17,17,18,19,8,8,8,9,9,2,2,3,3,3),ncol=5,byrow=TRUE) > library(plotrix) > barp(geac,names.arg=2014:2018,main="A level grades chemistry", > xlab="Year",ylab="Percentage of each grade",ylim=c(0,30), > col=c("white","lightblue","blue","orange","green","red","pink")) > > Jim > > On Fri, Aug 17, 2018 at 9:55 PM, <citc at disroot.org> wrote: >> R-users, >> >> Can someone please advise how to improve the code below that was used to produce the graph shown at the following hyperlink (https://chemistryinthecity.neocities.org/content/entry1808.html#17)? The request is to add space between the annual data groups. >> >> barplot(gceac[,3], xlab='year', ylab='percentage of each grade', col=c('aliceblue', 'aquamarine', 'blue', 'chocolate', 'darkgreen', 'firebrick', 'violet'), legend=gceac[1:7,2], args.legend = list(x = 40, y = 30, title='grades'), main='A-level grades, chemistry', beside=T, space=c(0,2), ylim=c(0,30)) >> years<-c(2014,2015,2016,2017,2018) >> mtext(years, side=1, at=c(5, 12, 19, 26, 33)) >> R-users, Can someone please advise how to improve the code below that was used to produce the graph shown at the following hyperlink (https://chemistryinthecity.neocities.org/content/entry1808.html#17)? The request is to add space between the annual data groups. barplot(gceac[,3], xlab='year', ylab='percentage of each grade', col=c('aliceblue', 'aquamarine', 'blue', 'chocolate', 'darkgreen', 'firebrick', 'violet'), legend=gceac[1:7,2], args.legend = list(x = 40, y = 30, title='grades'), main='A-level grades, chemistry', beside=T, space=c(0,2), ylim=c(0,30)) years<-c(2014,2015,2016,2017,2018) mtext(years, side=1, at=c(5, 12, 19, 26, 33))
August 17, 2018 10:24 PM, "Rolf Turner" <r.turner at auckland.ac.nz> wrote:> On 18/08/18 02:37, David L Carlson wrote: > >> Notice below that your message is substantially scrambled. R-Help is a >> plain text only list so you should set your email client to produce plain text messages.Apologies, forgot to change the default settings of the web-mail.> > If one struggles through the garbled html bumff, one sees that the OP *did* indeed use the "space=" > argument. However it does not appear to have had the desired effect, and I cannot see why. Since > the OP did not supply the data, I cannot experiment. >csv data below: year,grade,percentage 2014,A*,9 2014,A,23 2014,B,27 2014,C,19 2014,D,13 2014,E,7 2014,U,2 2015,A*,9 2015,A,23 2015,B,27 2015,C,19 2015,D,13 2015,E,7 2015,U,2 2016,A*,8 2016,A,23 2016,B,27 2016,C,19 2016,D,13 2016,E,7 2016,U,3 2017,A*,8 2017,A,23 2017,B,24 2017,C,20 2017,D,14 2017,E,8 2017,U,3 2018,A*,8 2018,A,22 2018,B,23 2018,C,20 2018,D,15 2018,E,8 2018,U,3