[R] URGENT help-Problem with panel barplot spacing

Kwesi A. Quagraine @t@r@kykwe@| @end|ng |rom gm@||@com
Tue May 28 12:42:08 CEST 2019


Hello All,

I am struggling to control the spaces between barplots I have panelled. I
would be grateful for any help in reducing the spaces between the plots.
For instance, how I can reduce distance between 1 and 2, 2 and 3 etc.

I would appreciate any help on this.

Thanks

Here’s a snippet of my code and attached is the current image I generate
from the command;

##for djf
postscript("fig_paper2_fre_obs_models_djf_1980_2013_4x3_new.eps",width=10,height=8,paper="special",horizontal=T,onefile=T)

par(mfrow=c(3,4))
par(mar=c(6,11,1,2))

a =1
for (j in a) {
  djf.bar<- barplot(djf.gcms[,j],ylim=c(0,9),xlim=c(0,50),col=cores1,main =
j,type="n",font.main = 1, cex.main = 1.5,las=1, axisnames = T, width =
0.8,cex.names=1.5,horiz = TRUE)
  abline(v=c(seq(0,50,10)),col='grey',lwd=0.2)
  par(new=TRUE)
  djf.bar<-barplot(djf.gcms[,j],ylim=c(0,9),xlim=c(0,50),col=cores1,main =
j,font.main = 1, cex.main = 1.5,las=1, axisnames = T, width =
0.8,cex.names=1.5,horiz = TRUE)
  ## Add text at top of bars
  text(y = djf.bar, x = djf.gcms[,j], label = round(djf.gcms[,j],
digits=0), pos = 4, cex = 1.2)
}


for (i in 2:4) {
  djf.bar<-barplot(djf.gcms[,i],ylim=c(0,9),xlim=c(0,50),col=cores1,main =
i, yaxs="i",type="n",font.main = 1, cex.main = 1.1,las=1, axisnames =
FALSE, width = 0.8,cex.names=1.0,horiz = TRUE)
  abline(v=c(seq(0,50,10)),col='grey',lwd=0.2)
  par(new=TRUE)
  djf.bar<-barplot(djf.gcms[,i],ylim=c(0,9),xlim=c(0,50),col=cores1,main =
i, yaxs="i",font.main = 1, cex.main = 1.1,las=1, axisnames = FALSE, width =
0.8,cex.names=1.0,horiz = TRUE)
  text(y = djf.bar, x = djf.gcms[,i], label = round(djf.gcms[,i],
digits=0), pos = 4, cex = 1.0)

}

b=5
for (k in b) {
  djf.bar<-barplot(djf.gcms[,k],ylim=c(0,9),xlim=c(0,50),col=cores1,main =
k,type="n",font.main = 1, cex.main = 1.1,las=1, axisnames = T, width =
0.8,cex.names=1.5,horiz = TRUE)
  abline(v=c(seq(0,50,10)),col='grey',lwd=0.2)
  par(new=TRUE)
  djf.bar<-barplot(djf.gcms[,k],ylim=c(0,9),xlim=c(0,50),col=cores1,main =
k,font.main = 1, cex.main = 1.1,las=1, axisnames = T, width =
0.8,cex.names=1.5,horiz = TRUE)
  text(y = djf.bar, x = djf.gcms[,k], label = round(djf.gcms[,k],
digits=0), pos = 4, cex = 1.2)

}

for (n in 6:8) {
  barplot(djf.gcms[,n],ylim=c(0,9),xlim=c(0,50),col=cores1,main =
n,type="n",font.main = 1, cex.main = 1.1,las=1, axisnames = FALSE, width =
0.8,cex.names=1.0,horiz = TRUE)
  abline(v=c(seq(0,50,10)),col='grey',lwd=0.2)
  par(new=TRUE)
  barplot(djf.gcms[,n],ylim=c(0,9),xlim=c(0,50),col=cores1,main =
n,font.main = 1, cex.main = 1.1,las=1, axisnames = FALSE, width =
0.8,cex.names=1.0,horiz = TRUE)
  text(y = djf.bar, x = djf.gcms[,n], label = round(djf.gcms[,n],
digits=0), pos = 4, cex = 1.0)

}

c = 9
for (m in c) {
  djf.bar<-barplot(djf.gcms[,m],ylim=c(0,9),xlim=c(0,50),col=cores1,main =
m,type="n",font.main = 1, cex.main = 1.1,las=1, axisnames = T, width =
0.8,cex.names=1.5,horiz = TRUE)
  abline(v=c(seq(0,50,10)),col='grey',lwd=0.2)
  par(new=TRUE)
  djf.bar<-barplot(djf.gcms[,m],ylim=c(0,9),xlim=c(0,50),col=cores1,main =
m,font.main = 1, cex.main = 1.1,las=1, axisnames = T, width =
0.8,cex.names=1.5,horiz = TRUE)
  title("Frequency (%)", line = -17.0)
  text(y = djf.bar, x = djf.gcms[,m], label = round(djf.gcms[,m],
digits=0), pos = 4, cex = 1.2)

}

for (i in 10:12) {
  djf.bar<-barplot(djf.gcms[,i],ylim=c(0,9),xlim=c(0,50),col=cores1,main =
i,type="n",font.main = 1, cex.main = 1.1,las=1, axisnames = F, width =
0.8,cex.names=1.0,horiz = TRUE)
  abline(v=c(seq(0,50,10)),col='grey',lwd=0.2)
  par(new=TRUE)
  djf.bar<-barplot(djf.gcms[,i],ylim=c(0,9),xlim=c(0,50),col=cores1,main =
i,font.main = 1, cex.main = 1.1,las=1, axisnames = F, width =
0.8,cex.names=1.0,horiz = TRUE) #xlab="Frequency (%)"
  title("Frequency (%)", line = -17.0)
  text(y = djf.bar, x = djf.gcms[,i], label = round(djf.gcms[,i],
digits=0), pos = 4, cex = 1.0)

}
dev.off()



------------
Try not to become a man of success but rather a man of value- Albert
Einstein

Kwesi A. Quagraine
Department of Physics
School of Physical Sciences
College of Agriculture and Natural Sciences
University of Cape Coast
Cape Coast, Ghana

Alt. Email: kwesi using csag.uct.ac.za
Web: http://www.recycleupghana.org/
Office: +27 21 650 3164
Skype: quagraine_cwasi


More information about the R-help mailing list