[R] Panel barplot with error bars on one bar
Kwesi A. Quagraine
@t@r@kykwe@| @end|ng |rom gm@||@com
Thu Nov 28 01:19:09 CET 2019
I have been able to solve my problem. Please don’t bother. Thanks
On 28 November 2019 at 02:00:30, Kwesi A. Quagraine (starskykwesi using gmail.com)
wrote:
Dear All,
I have been able to make a grouped panel bar plot (please see attached), I
am however trying to add error bars to one of the bar plots (ERA-interim)
across the panel and failing.
I am able to do that for just the first marplot, but my loop to apply to
the others is failing. Here’s a snippet of my code and I will be grateful
for any help. The snippet below shows what I have tried to do to apply to
panels 2:4.
——snip——
postscript(“test.eps",width=10,height=8,paper="special",horizontal=T,onefile=T)
par(mfrow=c(3,4))
#par(mar=c(8.8,3.5,1.0,0), oma = c(4, 4, 3, 3)) # spaces in the order of
c(bottom,left,top,right)
par(mar=c(6,7,1,1))
era_ci = jja.all.b.per[1,]
a =1
for (j in a) {
jja.bar<- barplot(jja.gcms[,j],ylim=c(0,9),xlim=c(0,25),col=cores1,main =
j,type="n",font.main = 1, cex.main = 1.1,las=1, axisnames = T, width =
0.8,cex.names=1.0,horiz = TRUE)
abline(v=c(seq(0,25,5)),col='grey',lwd=0.2)
par(new=TRUE)
jja.bar<-barplot(jja.gcms[,j],ylim=c(0,9),xlim=c(0,25),col=cores1,main =
j,font.main = 1, cex.main = 1.1,las=1, axisnames = T, width =
0.8,cex.names=1.0,horiz = TRUE)
## Add text at top of bars
text(y = jja.bar, x = jja.gcms[,j], label = round(jja.gcms[,j],
digits=0), pos = 4, cex = 1.0)
}
arrows(x0= (era_ci[1] + sd(era_ci)), x1 = (era_ci[1] - sd(era_ci)), y0 =
jja.bar[1,1], angle = 90, code = 3, length = 0.045)
for (i in 2:4) {
jja.bar<-barplot(jja.gcms[,i],ylim=c(0,9),xlim=c(0,25),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,25,5)),col='grey',lwd=0.2)
par(new=TRUE)
jja.bar<-barplot(jja.gcms[,i],ylim=c(0,9),xlim=c(0,25),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 = jja.bar, x = jja.gcms[,i], label = round(jja.gcms[,i],
digits=0), pos = 4, cex = 1.0)
arrows(x0= (era_ci[i] + sd(era_ci)), x1 = (era_ci[i] - sd(era_ci)), y0 =
jja.bar[1,i], angle = 90, code = 3, length = 0.045)
}
b=5
for (k in b) {
jja.bar<-barplot(jja.gcms[,k],ylim=c(0,9),xlim=c(0,25),col=cores1,main =
k,type="n",font.main = 1, cex.main = 1.1,las=1, axisnames = T, width =
0.8,cex.names=1.0,horiz = TRUE)
abline(v=c(seq(0,25,5)),col='grey',lwd=0.2)
par(new=TRUE)
jja.bar<-barplot(jja.gcms[,k],ylim=c(0,9),xlim=c(0,25),col=cores1,main =
k,font.main = 1, cex.main = 1.1,las=1, axisnames = T, width =
0.8,cex.names=1.0,horiz = TRUE)
text(y = jja.bar, x = jja.gcms[,k], label = round(jja.gcms[,k],
digits=0), pos = 4, cex = 1.0)
}
for (n in 6:8) {
barplot(jja.gcms[,n],ylim=c(0,9),xlim=c(0,25),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,25,5)),col='grey',lwd=0.2)
par(new=TRUE)
barplot(jja.gcms[,n],ylim=c(0,9),xlim=c(0,25),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 = jja.bar, x = jja.gcms[,n], label = round(jja.gcms[,n],
digits=0), pos = 4, cex = 1.0)
}
c = 9
for (m in c) {
jja.bar<-barplot(jja.gcms[,m],ylim=c(0,9),xlim=c(0,25),col=cores1,main =
m,type="n",font.main = 1, cex.main = 1.1,las=1, axisnames = T, width =
0.8,cex.names=1.0,horiz = TRUE)
abline(v=c(seq(0,25,5)),col='grey',lwd=0.2)
par(new=TRUE)
jja.bar<-barplot(jja.gcms[,m],ylim=c(0,9),xlim=c(0,25),col=cores1,main =
m,font.main = 1, cex.main = 1.1,las=1, axisnames = T, width =
0.8,cex.names=1.0,horiz = TRUE)
title("Frequency (%)", line = -19.0)
text(y = jja.bar, x = jja.gcms[,m], label = round(jja.gcms[,m],
digits=0), pos = 4, cex = 1.0)
}
for (i in 10:12) {
jja.bar<-barplot(jja.gcms[,i],ylim=c(0,9),xlim=c(0,25),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,25,5)),col='grey',lwd=0.2)
par(new=TRUE)
jja.bar<-barplot(jja.gcms[,i],ylim=c(0,9),xlim=c(0,25),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 = -19.0)
text(y = jja.bar, x = jja.gcms[,i], label = round(jja.gcms[,i],
digits=0), pos = 4, cex = 1.0)
}
dev.off()
Any help will be much appreciated.
Regards
Kwesi
------------
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
------------
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
[[alternative HTML version deleted]]
More information about the R-help
mailing list