xyplot:所有面板上的重复刻度线

xyplot : repeated tick marks on all panels

我正在绘制 xyplot 面板 R。看起来不错,但我希望在每个面板中重复刻度线(10、20、30,...)。

xyplot 是否可行,或者我应该切换到 ggplot(如果是,如何)?

最小工作示例:

library(lattice)
productcountry <- rep(c("United Kingdom","USA"),each=20)
productname <- rep(rep(c("Tea","Cornflakes"),each=10),times=2)
productprice <- c(c(10,12,18,26,35,45,50,58,59,60),c(20,25,40,45,46,49,53,55,61,61),c(10,12,16,25,33,41,48,52,56,61),c(25,27,34,40,43,47,50,52,54,55))
productqty <- c(c(33,29,30,35,37,21,25,30,28,34),c(40,34,29,28,25,20,17,14,10,4),c(41,39,32,30,26,23,20,16,15,12),c(22,26,23,19,28,25,26,20,24,22))
elasticitydata <- data.frame(productcountry,productname,productqty,productprice)
colnames(elasticitydata) <- c("Country","Product","Quantity","Price")
elasticityplot <- xyplot(Quantity ~ Price | Country + Product, data = elasticitydata, type = c("g","p","smooth"))

输出:

就这么简单:

update(elasticityplot, scales = list(alternating = 3))

注意scales也可以在xyplot里面指定,即

xyplot(..., scales = list(alternating = 3))