突出显示一个栏并在使用填充时分别用数字标记

时间:2019-02-25 20:28:37

标签: r ggplot2 geom-text

我正在尝试创建一个具有x,y和填充的图形。我还希望它使最大的酒吧比其他酒吧更加突出。另外,我想用每个栏的平均收入来标记。但是,我遇到了两个问题。

代码:

fruit <- df %>%
 filter(flavor == "FRUIT") %>%
   group_by(Promo_ad_both, Quarter) %>%
   summarise(avg_rev = mean(revenue)) %>%
ggplot(aes(x = Quarter, y = avg_rev, fill = reorder(Promo_ad_both, avg_rev))) +
geom_bar(stat = "identity", position = "dodge") +
ggtitle("Fruit Average Revenue by Quarter",
      sub = "Fourth Quarter with a small ad and Promo is best performer") +
xlab("Quarterly Revenue by Promo/Ad group") +
ylab("Average Revenue") +
guides(fill = guide_legend(title = "Promo and Ad type")) +
geom_text(aes(label= round(avg_rev, 0)), vjust=-0.2) +
theme_classic() +
coord_flip()

结果如下:

enter image description here

我想让第四季度的紫色条更加突出。有没有人建议去解决这个问题?

谢谢!

0 个答案:

没有答案