2016-04-05 4 views
3

xyplotのパネルをRにプロットしています。それは良いようですが、すべてのパネルで目盛り(10,20,30、...)を繰り返すことをお勧めします。 xyplot:すべてのパネルで繰り返し目盛りを表示

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

答えて

2

それはそれと同じくらい簡単です。

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

scatterplot

xyplot内で指定することができることを

は注意、すなわち、あなたは正確に `alternating`が何を説明することができ、完璧に動作

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

? – Marijn

+0

確かに@Marijn。 'alternating'では、' 'xyplot'から取り出された、軸ラベルがパネルグループの片側からもう片方へ交互に表示されるかどうかを指定することができます。この特定の場合、 'alternating = 3'は、マルチパネルプロットの軸ラベルを両側に描画する必要があることを示します。 – fdetsch

関連する問題