【发布时间】:2021-06-06 03:59:00
【问题描述】:
当我将 geom_text 添加到 geom_bar 时,整个情节变得一团糟。
> x
# A tibble: 3 x 6
# Groups: Jahr, Monat, Bez [3]
Jahr Bez TWh Total Monat MonatsEAnteil
<chr> <fct> <dbl> <dbl> <chr> <dbl>
1 2000 Kleinwasserkraft 0.2 12 Dec 0.0167
2 2000 Speicherkraft 20.3 22856 Jan 1.93
3 2000 Speicherkraft 20.3 22856 Feb 1.30
ggplot (data = x, aes(x=Monat, y=MonatsEAnteil, fill = MonatsEAnteil))+
-
geom_col(aes(fill = Bez))
> ggplot (data = x, aes(x=Monat, y=MonatsEAnteil, fill = factor(MonatsEAnteil)))+
+ geom_col(aes(fill = Bez))+
+ geom_text(aes (label = MonatsEAnteil), size = 3,
position = position_stack(vjust = 0.5))
删除第二行 (geom_text) 使其再次正常。使用 geom_text 它创建一个图例(对于每个值?)。
【问题讨论】:
-
如我所见,您没有包含minimal reproducible example(有几个未定义的变量)
-
对不起,我是新来的。试图纠正。
标签: r ggplot2 geom-bar geom-text