我做了下面的图,问题是我希望hline在几何条之上。此外,我想知道我是否可以在hline附近显示一些文本。目前,这是结果:
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
只需将geom_hline
调用移动到geom_col
之后,它就会显示在栏前。