Michael Eisenring
2011-Aug-25 08:45 UTC
[R] How to vary the distance between the pairs of a side-by-side barplot?
Hello, for my project I wanted to create a side-by-side barplot. For each of 143 treatments there are always two measurement. This two measurements (a pair) are represented by a red resp. a yellow bar. I was able to write the code for the side-by-side barplot. Unfortunately however I am not able to vary the distance between the measurement pairs ( the distance from one red-yellow bar pair to the next). How can I do this in the case of a side-by-side barplot? In a normal barplot this can be done by using the command: "space()" but in the case of a side-by-side barplot it is not working( in fact if I work with the "space" command R is changing somehow the coloration of my bars). I would be very grateful if anyone could help me with my problem. Thank you very much My R code: barplot(t(data), beside = TRUE,ylim=c(0,200),col=c("red","yellow"),main="Species rank curve",ylab="Number of individuals") Yours sincerely M.Eisenring PS: This is the first time I am using the R mailing list. Please let me know if I made any mistakes regarding the manner in which questions should be asked etc.
Jean V Adams
2011-Aug-25 12:44 UTC
[R] How to vary the distance between the pairs of a side-by-side barplot?
>From the help for barplot?barplot The argument "... space may be specified by two numbers, where the first is the space between bars in the same group, and the second the space between the groups. If not given explicitly, it defaults to c(0,1) if height is a matrix and beside is TRUE ..." So, try barplot(t(data), beside=T, ylim=c(0,200), space=c(0.2, 1), col=c("red","yellow"), main="Species rank curve", ylab="Number of individuals") or something like that. It's helpful to post a small subset of example data along with your code, so that folks can actually take it for a test drive. It's also helpful to post example code along with errors/warnings/output from attempts to solve the problem. You refer to an attempt to try using space, and said "it is not working" but didn't provide enough information for a reader to know what you tried and how it didn't work. Jean Michael Eisenring wrote on 08/25/2011 03:45:27 AM:> > Hello, > for my project I wanted to create a side-by-side barplot. For each > of 143 treatments there are always two measurement. This two > measurements (a pair) are represented by a red resp. a yellow bar. I > was able to write the code for the side-by-side barplot. > Unfortunately however I am not able to vary the distance between > the measurement pairs ( the distance from one red-yellow bar pair to > the next). How can I do this in the case of a side-by-side barplot? > In a normal barplot this can be done by using the command: "space()" > but in the case of a side-by-side barplot it is not working( in fact > if I work with the "space" command R is changing somehow the > coloration of my bars). > I would be very grateful if anyone could help me with my problem. > Thank you very much > > My R code: > > barplot(t(data), beside = TRUE,ylim=c(0,200),col=c > ("red","yellow"),main="Species rank curve",ylab="Number of individuals") > > Yours sincerely > M.Eisenring > > PS: This is the first time I am using the R mailing list. Please let > me know if I made any mistakes regarding the manner in which > questions should be asked etc.[[alternative HTML version deleted]]