R 将hline重叠到ggplot中
我已经做了以下的情节,事情是我希望hline位于geombars之上。此外,我想知道是否可以在hline附近显示一些文本。目前的结果是:R 将hline重叠到ggplot中,r,ggplot2,overlapping,geom-text,R,Ggplot2,Overlapping,Geom Text,我已经做了以下的情节,事情是我希望hline位于geombars之上。此外,我想知道是否可以在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 = 'da
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之后,它就会显示在栏前。当您在hline附近说文本时,您能提供更多细节吗?非常感谢您的第一个答案,我正在尝试在hline的左手边显示文本,也许它可以是一个geom_文本或geom_标签,我可以在其中显示值的平均值。每列的平均值是多少?还是该行的单个值?图像中的文本对于每一列都很好。如果您希望改进,请澄清您希望更改的内容。