我可以在嵌入饼图的R形条形图中制作这样的图形 [英] can I make such graph in R - bar chart embedded in pie chart

查看:148
本文介绍了我可以在嵌入饼图的R形条形图中制作这样的图形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下数据:

I have following data:

    I   II  Total 
A   15  25  40
B   5   45  50
C   15  5   20

R数据输入:

R data input:

group <- c("A", "B", "C", "A", "B", "C")
subgroup <- c("I", "I", "I", "II", "II", "II")
yvar <- c(15, 5, 15, 25, 45, 5)

当我在想一个更好的方式来呈现它时,我想到了饼图(最好是3D)结合条形图(最好是3D)。这是我的想法的粗略草图,条形图嵌入饼图中。如果您有任何其他创新想法来呈现此类数据,请告诉我。

As I was thinking a better way to present it, I came to idea of pie chart (preferably 3D) combined with bar chart (preferably 3D). Here is my rough sketch of my idea where bar chart is embedded into pie chart. Please suggest me if you have any other innovative idea to present such data.


< img src =https://i.stack.imgur.com/194oW.jpgalt =在这里输入图片描述>

推荐答案

来吧,放开馅饼吧!我建议你只选择馅饼专用解决方案 - 无论如何谁还需要条形图。只需获取 plotrix 包。

Come on, lets go wild with the pies! I suggest you just go for pie-only solution - who needs bar charts anyway. Just get plotrix package. Here is how I would display matrix of 6 numbers in the form of pie charts.

plot(1:5,type="n",main="Pie charts are evil",xlab="",ylab="",axes=FALSE)#empty plot
require(plotrix)
main_col <- c("#ff0000","#80ff00","#00ffff")#nice colors
main_pie <- floating.pie(3,3,c(40,50,20), col=main_col,radius=1)#your big pie
#here are your small pies with labels using plotrix functions
small_col <- c("black","white")
small_lab <- c("I","II")
A <- floating.pie(3.8,4.5,c(15,5), col=small_col,radius=0.2)
pie.labels(3.8,4.5,A,small_lab,border=F,radius=0.3,cex=0.8)
B <- floating.pie(1.7,2,c(15,25), col=small_col,radius=0.2)
pie.labels(1.7,2,B,small_lab,border=F,radius=0.3,cex=0.8)
C <- floating.pie(4.3,2,c(5,45), col=small_col,radius=0.2)
pie.labels(4.3,2,C,small_lab,border=F,radius=0.3,cex=0.8)
#and finally very useful legend
legend("right",legend=c("A","B","C"),col=main_col,bty="n",pch=15)

这篇关于我可以在嵌入饼图的R形条形图中制作这样的图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆