R-Lattice封装:1个x轴,用于多个y轴

时间:2012-11-21 03:24:04

标签: r lattice

我的问题与此类似: Plotting bar plot below xyplot with same x-axis?,但是对于格子包而不是ggplot。

我有21个xyplots,都有相同的x轴刻度,但不同的y轴刻度。我想绘制所有21行只有1个x轴,但21个不同的y轴刻度(每行一行)。我差不多在这里:21 xyplots, 1 x-axis,但是每个面板上印有多余的x轴使这个数字变得荒谬。我的剧本:

xyplot(numhr~year | spp, xlab = "Time(years)", 
ylab = "Abundance (# per party hr)", type = "l", aspect = "fill",
strip = FALSE, scales = list(relation = "free"), as.table = TRUE,
layout = c(1,21), xlim = c(1940,2010))

任何帮助?

〜凯文

1 个答案:

答案 0 :(得分:1)

根据上面的评论,对我的代码进行必要的更改以进行此项工作涉及添加' y = list(relation =" free")'到了#&c;尺度'零件。编辑后的代码:

xyplot(numhr~year | spp, xlab = "Time(years)", 
ylab = "Abundance (# per party hr)", type = "l", aspect = "fill",
strip = FALSE, scales = list(y = list(relation = "free")), as.table = TRUE,
layout = c(1,21), xlim = c(1940,2010))

产生这个(不幸的是,y轴仍然过于浓缩,但这确实解决了最初提出的问题): Improved xyplot with 1 x-axis