【发布时间】:2021-09-08 16:46:47
【问题描述】:
我正在尝试为迄今为止 F1 车手赢得的冠军制作华夫饼图。图表很好,但它带有字母标签。我希望它从赢得的冠军头衔最多开始到最少。
我尝试了 ordering 和 fct_relevel。但没有任何效果。下面是代码
ggplot(data = dfc, aes(fill=Champions, values=one)) +
geom_waffle(color = "cornsilk", size=0.25, n_rows=7)+
facet_wrap(~Champions, nrow = 3, strip.position = "bottom",labeller = label_wrap_gen(6))
这就是 result我在找。
你可以找到完整的代码here
数据集看起来像
Season Champions Team one
1 a x 1
2 a x 1
3 b y 1
4 a x 1
5 c z 1
【问题讨论】:
-
Error: At least one layer must contain all faceting variables: `Champions`。 (它不在您的示例数据中。) -
@r2evans 对不起,我的错。刚刚编辑过
-
请修剪您的代码,以便更容易找到您的问题。请按照以下指南创建minimal reproducible example。
-
您是否尝试过使用
fct_reorder? -
@RichardTelford 是的,也试过了。没用,但答案有效(fct_infreq)
标签: r ggplot2 visualization facet-wrap waffle-chart