在叠加的直方图中添加平均值

时间:2020-01-27 20:59:57

标签: r plot graph histogram

我想在覆盖的直方图中添加平均值。

我制作了这张图,并添加了中线,但我做不到。 我添加均值线,但无法添加均值。

enter image description here

我的r码是

cdat <- ddply(at_4c5_mapa1, "acuracias_atribuidas_5", summarise, rating.mean=mean(Valores, na.rm = FALSE))
ggplot(at_4c5_mapa1, aes(x = Valores, fill = acuracias_atribuidas_5)) + 
  geom_histogram(binwidth = 0.02, alpha = 0.5, position = "identity") +
  labs(title = "New plot title", subtitle = "A subtitle", x = "Acurácias Calculadas", y = "Frequência", caption = "(based on data from", tag = "A") +
  geom_vline(data=cdat, aes(xintercept=rating.mean, colour= acuracias_atribuidas_5),linetype="dashed", size=1) +
  theme(plot.title = element_text(hjust = 0.5), plot.subtitle = element_text(hjust = 0.5)) +
  labs(fill="Acurácia")

我的数据at_4c5_mapa1

Indices Acuracia
0.50    0.5004800
0.50    0.5159680
0.50    0.4460917
0.50    0.5325600
0.50    0.4759588
0.70    0.6874240
0.70    0.7306240
0.70    0.6069533
0.70    0.6835200
0.70    0.6074839
0.85    0.8124160
0.85    0.8774400
0.85    0.8239252
0.85    0.8460000
0.85    0.8894624
0.95    0.9504640
0.95    0.9308160
0.95    0.9428785
0.95    0.9261600
0.95    0.9381505

请帮助!

0 个答案:

没有答案