Skip to content
Prev 362767 / 398500 Next

probelm with xlab ylab and xaxp barplot

I am still struggling to have my slab and ylab displayed on a bar plot. Marc did useful advise on playing with mar settings. I tried may combinations and can?t have it work.

I paste the code I am suing hoping guidance on solving this issue.




## extract works for all time steps
d1<-read.nc(gp)

d2<-read.nc(er)

d3<-read.nc(me)

d4<-read.nc(ne)

d5<-read.nc(ar)

d6<-read.nc(cc)

d7<-read.nc(mr)

d8<-read.nc(ic)

z1<-d1$spei
z2<-d2$spei
z3<-d3$spei
z4<-d4$spei
z5<-d5$spei
z6<-d6$spei
z7<-d7$spei
z8<-d8$spei
#par(oma=c(2,2,2,2))  # all sides have 3 lines of space  

par(mar=rep(2,4))
#par(mar=c(5.1, 4.1, 2.1, 2.1))
#par(mai=c(1.02,0.82,0.82,0.42))
op <- par(oma=c(1,2,3,5))
#op <- par(oma=c(6,5,0,0))
par(mfrow=c(4,2))

line = 3

barplot(z1, ylim=c(-2,2), xlab="Years", ylab="spei", xaxp=c(181,2005,1), col=ifelse(z1>0,"green","brown"))

mtext("a")
barplot(z2,xlab="Years", ylab="spei",  ylim=c(-2,2), col=ifelse(z2>0,"green","brown"))
mtext("b")
barplot(z3, ylim=c(-2,2), xlab="Years", ylab="spei", col=ifelse(z3>0,"green","brown"))
mtext("c")
barplot(z4, xlab="Years", ylab="spei", ylim=c(-2,2), col=ifelse(z4>0,"green","brown"))
mtext("d")
barplot(z5, xlab="Years", ylab="spei", ylim=c(-2,2), col=ifelse(z5>0,"green","brown"))
mtext("e")
barplot(z6, xlab="Years", ylab="spei", ylim=c(-2,2), col=ifelse(z6>0,"green","brown"))
mtext("f")
barplot(z7,xlab="Years", ylab="spei",  ylim=c(-2,2), col=ifelse(z7>0,"green","brown"))
mtext("g")
barplot(z8,  ylim=c(-2,2), xlab="Years", ylab="spei", col=ifelse(z8>0,"green","brown"))
mtext("h")
par(op)

Another solution with ggplot2 or lattice also welcome.


Best regards,

asarr