作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Seasons Frequency1 Frequency2
DJF 497 500
JJA 999 700
MAM 695 2000
SON 245 1000
嗨,我正在使用此数据框制作多个饼图(一个使用Frequency1,另一个使用Frequency2)。我知道如何使用melt和facet_wrap(~id)。但这里我必须汇集数据(不知道如何表达)。我不想按季节进行 Facet_wrap。
如何以可以并排制作两个饼图的方式融合数据。我仅使用Frequency1 制作了一个。
谢谢!
最佳答案
这是一种使用ggplot2
生成带有分面的饼图的方法。
数据:
dat <- read.table(text = "Seasons Frequency1 Frequency2
DJF 497 500
JJA 999 700
MAM 695 2000
SON 245 1000", header = TRUE)
将数据转换为长格式:
library(reshape2)
dat2 <- melt(dat)
创建情节:
library(ggplot2)
ggplot(dat2, aes(x = "", y = value, fill = Seasons)) +
geom_bar(stat = "identity", width = 1, position = position_fill()) +
coord_polar(theta = "y") +
facet_wrap( ~ variable)
关于r - 如何使用饼图来使用facet_wrap?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25372055/
有人可以帮我理解为什么我的饼图百分比计算不正确吗?看截图: 根据我的计算,如 RHS 上所示,支出百分比应为 24.73%。传递给 Highcharts 的值如下:- 花费:204827099.36-
我正在制作圆环饼图。 我设置数据的颜色并获取钻取(它是保存外部切片的数据和配置的对象)切片的颜色为同一组颜色。我想设置要在向下钻取对象中使用的不同颜色数组。请参阅附图(外层切片有两种颜色:橙色和透明)
我是一名优秀的程序员,十分优秀!