r - ggplot 使用小饼图作为带有 geom_point 的点

标签 r ggplot2 data-visualization pie-chart

我想用 ggplot 制作一个图表,如下所示。
这个想法是在两个分类变量之间绘制“百分比匹配”。
通过改变点的大小很容易接近,但我想知道是否可以制作这些小饼图......

使用点的大小作为分数的度量来绘制此示例代码。

temp <- data.frame(Exercise=c(1, 1, 1, 2, 2, 2), 
    Name=c(1, 2, 3, 1, 2, 3), Score=c(0.2, 0.5, 0.3, 0.9, 1.0, 0.6))
ggplot(temp) + geom_point(aes(Exercise, Name, size=Score))

如何更改此代码以提供接近下图的内容?

example chart

最佳答案

使用绘图作为点的形状很棘手。但是,您可以回避问题并使用 facet_grid() 非常接近您的模型:

ggplot(temp) + 
  geom_bar(aes(x=1, y=Score), stat="identity") + 
  facet_grid(Exercise~Name) + 
  coord_polar(theta = "y") +
  scale_y_continuous(breaks = NULL) +
  scale_x_continuous(name = element_blank(), breaks = NULL)

enter image description here

关于r - ggplot 使用小饼图作为带有 geom_point 的点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14215696/

相关文章:

php - 从 wordpress 安装运行 exec() Rscript

r - 在 R shiny 和 leaflet 中过滤和选择点

r - ggplot : weighted. 多面条形图中的平均值和 stat_summary

r - 在 geom_smooth 中更改线条边框颜色

python - Pandas 和 Plotly : how to access data columns in the hover text that are not used to plot the point?

将唯一列表中的 NA 替换为 R 中第二个列表中相同位置的 NA

r - 如何将多列中的 NA 替换为同一数据集中其他相应多列的值?

r - ggplot2:基于颜色以外的变量进行位置躲避

r - 如何使用ggplot2绘制多个区域图?

python - 带有百分比标签的python中的圆形条形图