将hline重叠到ggplot中

问题描述 投票:0回答:1

我绘制了以下图,但事实是我希望将hline放在geombals上方。此外,我想知道是否可以在行附近显示一些文本。目前,这是结果:

sent%>%
  ggplot(aes(sent$screen_name,(as.numeric(sent$ave_sentiment)))) +
  geom_hline(yintercept = (sum(sent$ave_sentiment)/15), color='black',size=1.25)+
  geom_col(fill = 'darkred') + 
  theme_minimal(base_size = 14) +
  xlab(NULL) + ylab(NULL) +
  geom_text(aes(label = (sent$ave_sentiment), y =(sent$ave_sentiment)+12), position = position_dodge(0.9), vjust =0.5,size=3)+
  scale_x_discrete(limits = sent$screen_name) + ylim(0,100)+ coord_flip()+
  ggplot2::labs(
    x = NULL, y = NULL, #Info en cada eje 
    title = "Índice de negatividad por medio " #Texto 
  )

  [1]: https://i.stack.imgur.com/yQ3JW.png
r ggplot2 overlapping geom-text
1个回答
0
投票

只需将geom_hline调用移动到geom_col之后,它将显示在小节的前面。

© www.soinside.com 2019 - 2024. All rights reserved.