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

David L Carlson dcarlson at tamu.edu
Tue Jan 22 15:33:02 CET 2013


Most attachments are automatically stripped from r-help so we cannot see
your results. You may be able to get what you want with pyramid.plot in
package plotrix by changing the default values (it is designed for
population pyramids) or you may be able to get there using the layout()
function in base graphics before your plotting commands. Alternatively you
can set up a plot and then use the polygon() function to place the
rectangles where you want them.

----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Purna chander
> Sent: Tuesday, January 22, 2013 3:41 AM
> To: r-help
> Subject: [R] How to remove the vertical space between two graps
> 
> 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