r - position_dodge on geom_text on dodged barplot
问题描述
My DF looks like this:
Date H2 Value
2018-06-04 H2_Avg 0.08
2018-06-07 H2_Avg 0.11
2018-06-16 H2_Avg 0.12
2018-06-20 H2_Avg 0.13
2018-06-23 H2_Avg 0.24
2018-06-26 H2_Avg 0.16
2018-06-30 H2_Avg 0.24
2018-07-04 H2_Avg 0.38
2018-07-09 H2_Avg 0.44
2018-07-12 H2_Avg 0.34
2018-06-04 H2_disabled 0.07
2018-06-07 H2_disabled 0.09
2018-06-16 H2_disabled 0.10
2018-06-20 H2_disabled 0.14
2018-06-23 H2_disabled 0.23
2018-06-26 H2_disabled 0.18
2018-06-30 H2_disabled 0.22
2018-07-04 H2_disabled 0.33
2018-07-09 H2_disabled 0.27
2018-07-12 H2_disabled 0.24
I want to plot a dodged barplot with the values written within the columns. My code to plot looks like this:
DF %>% ggplot() +
geom_col(aes(Date, Value, fill = H2), position = "dodge") +
geom_text(aes(Date, Value, label = Value),
position = position_dodge(width = 1),
vjust = 1.5)
This outputs the following:
As you can see, the values specified by geom_text
are not legible where the differences between the two columns are small.
Is there a way to improve this?
Flipping the coordinates and then using the position_dodge
argument as proposed here: Position geom_text on dodged barplot does not work for my data due to the small differences between the two groups.
解决方案
推荐阅读
- vba - 我可以加速此 VBA 以移动电子邮件吗?
- selenium - Appium 使用页面对象工厂总是返回空指针异常
- python - Python中的固定关系笛卡尔积
- javascript - Allow spaces only at the start and end of the string in JavaScript
- neo4j - 多个 UNWIND 处理空列表
- python - 在 Flask 中渲染(许多)模板
- python - pandas 将 dict 嵌套不平衡 dict 转换为数据框
- apache-flink - Apache Flink 1.4.2 akka.actor.ActorNotFound
- docker - cp-kafka-connect 是开源组件还是专有组件?
- excel - 循环创建数据透视表和条形图