我尝试过各种方法来获得facet_grid
ggplot2 中的饼图根据另一个变量(强度)改变宽度/半径。
geom_bar 接受 width=0.5 作为参数,但它被忽略一次coord_polar
被添加。Adding width=0.5
到 ggplotaes
或添加一个aes
to 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())