I have the following data set:
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")
I want to create plot where each panel looks somewhat like the panels below:
However, I want to have all panels stacked on top of one another, with no space between panels, and with only 1 x-axis since they all share a common x-axis. I used the following code to produce this plot:
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
I also want the labels '548', '331', and '126 removed from the top of each plot, change the line colors to black and change one of the lines to a dashed line, and have only 1 y-axis and x-axis label.
I would prefer this to be accomplished in GGPlot2 if possible, but Lattic may be the only way to do this. Any help that you can provide would be greatly appreciated!