R ggplot2中具有可变饼图大小的饼图

R ggplot2中具有可变饼图大小的饼图,r,charts,ggplot2,pie-chart,R,Charts,Ggplot2,Pie Chart,我尝试了各种方法来获得ggplot2中饼图的facet\u网格,以根据另一个变量(强度)改变宽度/半径 geom_bar接受宽度=0.5作为参数,但一旦添加了coord_polar,它将被忽略将宽度=0.5添加到ggplotaes或将aes添加到geom_条不起作用。我看不到coord\u polar的任何其他相关选项。最简单的方法是什么?下面的代码生成了一个很好的饼图网格,但不会更改饼图的大小。我错过了什么 mydata <- data.frame(side1=rep(LETTERS[1

我尝试了各种方法来获得ggplot2中饼图的
facet\u网格
,以根据另一个变量(强度)改变宽度/半径

geom_bar接受宽度=0.5作为参数,但一旦添加了
coord_polar
,它将被忽略<代码>将宽度=0.5添加到ggplot
aes
或将
aes
添加到
geom_条
不起作用。我看不到
coord\u 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()) 
mydata你的意思是这样吗

ggplot(mydata, aes(x=strength/2, y = val, fill = widget, width = strength)) +
  geom_bar(position="fill", stat="identity") + 
  facet_grid(side1 ~ side2) + 
  coord_polar("y") + 
  opts(axis.text.x = theme_blank()) 

就是这样!现在有意义了,在非极性系统中,这些条必须左对齐。我仍然有点不清楚为什么strength/2是一个神奇的数字,但是我需要更多地阅读aes如何处理geom_bar中的x值。