2

如何在 R latticeExtra DoubleYscale 图中设置 y 轴范围和刻度线?我希望两个 xyplot 中的主要和次要 y 轴刻度和刻度线相同。下面是我的 R 代码。目前,在地块 1 中,主要 y 比例从 -3 到 0,次要 y 比例从 -150 到 0。在地块 2 中,主要 y 比例从 -2 到 0,次要 y-比例是从-200 到 0。
我想要两个图的主要 y 比例是从 -3 到 0,次要 y 比例是从 -200 到 0,并且能够设置两个图中的刻度数。谢谢。

#load workspace stol and stoh
library(latticeExtra)
library(gridExtra)
plot1<-xyplot(percentloss*100 ~ time, groups=cap, pch=16,axis = axis.grid,
abline=c(list(h=c(0,-0.5,-1,-1.5,-2,-2.5,-3)),trellis.par.get("reference.line")),
main="Storage; 5 mL fill vol",
xlab="Time (hours)",
ylab="Evaporative loss (%)" ,
auto.key=list(border=TRUE), 
par.settings = simpleTheme(pch=16), scales=list(x=list(relation='same'), 
y=list(relation='same')),
data=stol)
plot2<-xyplot(absoluteloss*1000 ~ time, groups=cap, pch=16,
main="    ",
xlab="Time (hours)",
ylab="Absolute loss (uL)" ,
 data=stol)
plota<-doubleYScale(plot1, plot2, style1 = 0, style2 = 0, add.ylab2 = T)
plot3<-xyplot(percentloss*100 ~ time, groups=cap, pch=16,axis = axis.grid,
abline=c(list(h=c(0,-0.5,-1,-1.5,-2,-2.5,-3)),trellis.par.get("reference.line")),
main="Storage; 10 mL fill vol",
xlab="Time (hours)",
ylab="Evaporative loss (%)" ,
auto.key=list(border=TRUE), 
par.settings = simpleTheme(pch=16), scales=list(x=list(relation='same'), 
y=list(relation='same')),
data=stoh)
plot4<-xyplot(absoluteloss*1000 ~ time, groups=cap, pch=16,
main="    ",
xlab="Time (hours)",
ylab="Absolute loss (uL)" ,
data=stoh)
plotb<-doubleYScale(plot3, plot4, style1 = 0, style2 = 0, add.ylab2 = T)
grid.arrange(plota,plotb, ncol=2)
4

0 回答 0