【发布时间】:2014-07-16 02:11:37
【问题描述】:
我尝试了各种方法来获取 ggplot2 中的饼图 facet_grid,以根据另一个变量(强度)改变宽度/半径。
geom_bar 接受 width=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())
【问题讨论】:
标签: r charts ggplot2 pie-chart