gpt4 book ai didi

r - xyplot : repeated tick marks on all panels

转载 作者:行者123 更新时间:2023-12-01 02:01:00 25 4
gpt4 key购买 nike

我正在策划一个 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"))

输出:

enter image description here

最佳答案

就这么简单:

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

scatterplot

请注意 scales也可以在 xyplot里面指定, IE。
xyplot(..., scales = list(alternating = 3))

关于r - xyplot : repeated tick marks on all panels,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36426227/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com