hur*_*urf 7 charts r ggplot2 pie-chart
我已经尝试了各种方法来获取facet_gridggplot2中的饼图,以根据另一个变量(强度)改变宽度/半径.
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())
Run Code Online (Sandbox Code Playgroud)
koh*_*ske 19
你的意思是这样的吗?
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())
Run Code Online (Sandbox Code Playgroud)
