Skip to content
Prev 247193 / 398503 Next

Grouped bars in barplot

Tena koe Steve

Convert your data into a matrix:

dataMat <- matrix(c(bline_precip[10,9], bline_runoff[10,9],
                    cccma_precip[10,9], cccma_runoff[10,9],
                    csiro_precip[10,9], csiro_runoff[10,9],
                    ipsl_precip[10,9], ipsl_runoff[10,9],
                    mpi_precip[10,9], mpi_runoff[10,9],
                    ncar_precip[10,9], ncar_runoff[10,9],
                    ukmo_precip[10,9], ukmo_runoff[10,9]), nrow=2)

Since I don't know the nature of your data I will use a simple example:

dataMat <- matrix(1:14, nrow=2)
barplot(dataMat, beside=TRUE, space=c(0,2))
tTicks <- barplot(dataMat, beside=TRUE, space=c(0,2))
tTicks <- tapply(tTicks, rep(1:7, each=2), mean)
axis(1, tTicks, letters[1:7])

Is that what you want?

HTH ....

Peter Alspach
The contents of this e-mail are confidential and may be subject to legal privilege.
 If you are not the intended recipient you must not use, disseminate, distribute or
 reproduce all or any part of this e-mail or attachments.  If you have received this
 e-mail in error, please notify the sender and delete all material pertaining to this
 e-mail.  Any opinion or views expressed in this e-mail are those of the individual
 sender and may not represent those of The New Zealand Institute for Plant and
 Food Research Limited.