[R] [FORGED] Re: bar plot add space to group data

Rolf Turner r@turner @end|ng |rom @uck|@nd@@c@nz
Sun Aug 19 01:52:50 CEST 2018


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 using 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))




More information about the R-help mailing list