[R] How to remove the vertical space between two graps

Purna chander chanderbio at gmail.com
Tue Jan 22 10:40:32 CET 2013


Hi,

I have created a barplot using the following code.

a<-c(11,23,15,34,42,31)
m<-matrix(a,nrow=2)
m[2,]<-(-1)*m[2,]

par(mar=c(4,4,4,0))
barplot(m[2,],horiz=T)

par(mar=c(4,0,4,2))
barplot(m[1,],horiz=T,col="black")

and the plot obtained is shown in "plot1.tiff".

I was not willing to see the gap (vertical space) between two graphs.
How can I achieve it?


Further I tried to achieve my goal in a single plot, for which I tried
this code:

a<-c(11,23,15,34,42,31)
m<-matrix(a,nrow=2)
m[2,]<-(-1)*m[2,]

barplot(m,horiz=T,beside=T)

and the plot obtained is showed in "plot2.tiff"

in the second attempt I'm able to place the bars next to each other
using "beside=T" argument. However, I fail when I use "beside=F"
argument (obtained plot3.tiff with this).

Can you suggest me in achieving my goal (similar to plot2 with no
vertical space)?

Regards,
Purna


More information about the R-help mailing list