7
我試過各種方法得到ggplot2餅圖的facet_grid
根據另一個變量(強度)變化寬度/半徑。ggplot2餅圖可變餡餅尺寸
geom_bar接受寬度= 0.5作爲參數,但一旦添加coord_polar
就會被忽略。 Adding width=0.5
到ggplot aes
或將aes
添加到geom_bar
不起作用。我看不到coord_polar
的其他相關選項。最簡單的方法是什麼?下面的代碼製作了一個很好的餅圖網格,但不會更改餅圖的大小。我錯過了什麼?
mydata <- data.frame(side1=rep(LETTERS[1:3],3,each=9),side2=rep(LETTERS[1:3],9,each=3),widget=rep(c("X","Y","Z"),9*3),val=runif(9*3),strength=rep(c(1,2,3),3,each=3))
ggplot(mydata, aes(x="",y = val, fill = widget, width = strength)) +
geom_bar(position="fill") + facet_grid(side1 ~ side2) +
coord_polar("y") + opts(axis.text.x = theme_blank())
這正是它!現在有道理,這些條必須在非極性系統中左對齊。我仍然有點不清楚爲什麼強度/ 2是神奇數字,但將不得不多做一些關於aes如何在geom_bar中處理x值的內容。 – hurfdurf 2011-12-24 20:27:28