Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Geom_text not alligned at the top of the bars

$
0
0

The geom_text labels are not centered at the top of the bars in the graph below, especially the last two labels (left to right):

enter image description here Does anyone have any ideas to align them at the top of the bars?

I have tried some code changes, but the best one I got was:

    my_df = data.frame(c('2017','2018','2019','2019','2019','2019','2020','2020'),c(96, 91, 20.59, 47.37, 78.12, 10.00, 15.00 ,91),c("No","No", "20%", "20%", "5%", "20%", "20%", "No"))

    colnames(my_df) <- c("Year","Threshold","Fee")

    colors <- c("No"="seagreen3","5%"="yellow2","20%"="red4")

    ggplot(data=my_df,aes(x=Year,y=Threshold,label=Threshold,group=Fee)) + 
geom_col(aes(fill = Fee),position = position_dodge2(width = 1, preserve = "single")) + geom_text(position = position_dodge2(width = 1),vjust=-0.5,size=2) + 
scale_fill_manual(values = cores2)

Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>