我有以下数据集:
structure(list(Male = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L), .Label = c("126", "331", "548"), class = "factor"),
Urban = c(43.36, 44.52, 44.77, 49.08, 47.88, 39.24, 41.75,
48.63, 49.95, 43.57, 41.94, 37.74, 40.97, 45.56, 45.65, 53.62,
58.19, 51.29, 51.85, 55.28, 55.66, 54.14, 49.4, 49.87, 44.81,
44.23, 47.99, 45.46, 44.9, 42.09, 57.23, 51.97, 46.85, 51.02,
41.56, 51.23, 44.79, 50.87, 46.6, 56.22, 46.98, 49.04, 50.07,
46.32, 48.75), LowFreq = c(3640, 3360.8, 3309.4, 3101.1,
3263.3, 3070, 3153.3, 3594, 4220, 3670, 3367.9, 3156.7, 3431,
3440.5, 3276.7, 3526.7, 3592.9, 3588.2, 3614.1, 3619.2, 3625.8,
3574.8, 3650, 3678.2, 3655.6, 3675.3, 3681.3, 3680.7, 3647.5,
3670, 2973.9, 2948.8, 2715.2, 2980.4, 2693.6, 2888.4, 2718.5,
2971, 2752.2, 3008.5, 2718.4, 2860.2, 2848, 2893.3, 2940.2
), idx = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1,
2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)), .Names = c("Male",
"Urban", "LowFreq", "idx"), row.names = c(NA, -45L), class = "data.frame")
我想创建每个面板看起来有点像下面的面板的情节:
但是,我希望将所有面板堆叠在一起,面板之间没有空间,并且只有 1 个 x 轴,因为它们都共享一个共同的 x 轴。我使用以下代码来生成此图:
awesome$idx<-ave(rep(1,nrow(awesome)),awesome$Male,FUN=seq_along)
free.y<-list(y=list(relation="free"))
require(lattice)
mA<-xyplot(Urban~idx|Male,data=awesome,type="l",scales=free.y)
mB<-xyplot(LowFreq~idx|Male,data=awesome,type="l",scales=free.y)
require(latticeExtra)
comb<-doubleYScale(mA,mB)
comb$x.between<-5
comb
我还希望从每个图的顶部删除标签“548”、“331”和“126”,将线条颜色更改为黑色并将其中一条线更改为虚线,并且只有 1 个 y 轴和 x -轴标签。
如果可能的话,我希望这在 GGPlot2 中完成,但 Lattic 可能是做到这一点的唯一方法。您可以提供的任何帮助将不胜感激!