How to edit ylab2 in doubleYScale?

Asked

Viewed 32 times

1

Hello, I need to edit ylab2, within the latticeExtra::doubleYScale.

inserir a descrição da imagem aqui

As you can see in the image, the axes captions, they’re different sizes, I need them to be cex=1.4.

follows the data:

clima<-structure(list(data = structure(c(15489, 15490, 15491, 15492, 
15493, 15494, 15495, 15496, 15497), class = "Date"), VV = c(1.63, 
2.87, 2.33, 2.33, 2.43, 0, 3.07, 4.47, 4.47), Tmax = c(29.63, 
30.63, 30.77, 29.97, 29.65, 30.1, 31.13, 31.53, 31.3), Tmin = c(19.6, 
15.32, 15.38, 14.98, 14.8, 15.05, 15.57, 15.77, 15.65), Tmed = c(24.62, 
22.98, 23.08, 22.48, 20.9, 22.58, 23.35, 23.65, 23.48), UR = c(79.8, 
74.6, 73.3, 79.3, 77.6, 72.9, 70.5, 70.4, 72.8), Ubu = c(54.72, 
46.31, 42.61, 35.19, 29.59, 27.15, 23.05, 16.77, 11.97), P = c(0, 
0, 0, 0, 0, 0, 0, 0, 0)), row.names = c(NA, -9L), class = "data.frame")

Code:

require(latticeExtra)
require(reshape2)
require(grid)
require(gridExtra)


 dados<-melt(clima[,c(1,3:5,8)], id.vars=1,measure.vars=2:4)
 dados$data<-ymd(dados$data)



lat1<-
  xyplot(value~data, groups=variable,data=dados,
       scales=list( x=list(at=dados$data,labels=format(dados$data,"%d/%m"))),
               type=c("l","p"),pch=c(15,16,17),lty=c(1,2,4),lwd=2,col=c("blue","red","black"),
             ylim =c(0,35),xlab="",ylab=list(expression("Temperatura ("^"º"*"C)"),cex=1.4),
             key=list(columns=1,space="bottom",
                      text=list("Tmáx"),lines=list(col="blue",type="b",lty=1,pch=15,lwd=2),
                      text=list("Tmín"),lines=list(col="red",type="b",lty=2,pch=16,lwd=2),
                      text=list("Tméd"),lines=list(col="black",type="b",lty=4,pch=17,lwd=2)))


lat2<-
barchart(P~data,data=clima,scales=list( x=list(at=dados$data,labels=format(dados$data,"%d/%m"))),
              horiz=FALSE,ylim=c(0,10),col="purple",
               xlab="",ylab=expression("Precipitação (mm d"^-1*")"),
               key=list(columns=1, text=list("P"),space="bottom",rectangle=list(col="purple")))

update(doubleYScale(lat1, lat2, add.ylab2 = TRUE,use.style = F))

When I put in lat2::ylab=list(expression("Precipitação (mm d"^-1*")"),cex=1.4), o R, no longer identifies as legend and replaces with "P".

I tried to use this solution, but it only changes the size of axis.text, as is to be expected!!

trellis.par.set(axis.text=list(cex=1.2))
 update(doubleYScale(lat1, lat2, add.ylab2 = TRUE,use.style = F))
  • For those interested: just put it on the first graph lat1' dentro de xyplot()&#xA; ylab.right = list(Expression("Precipitation (mm d" -1*")"),fontfamily="Times New Roman",rot=-90,cex=1.4), no caso eu to usando o pacote extrafont` to put in "Times New Roman".

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.