I want to show the exact value of each attribute on a bar chart in ggplot2 and also place the names of the attributes diagonally or somehow make them not overlap when there are many...
I would like an example please solve my doubt.
I appreciate your collaboration
Here is an example with a small data set. You may want to adjust some of the settings in the element_text() function to adapt the code to your data set.
library(ggplot2)
DF <- data.frame(Name = c("LontNameOne", "LongNameTwo", "LongNameThree"),
Values = c(25, 37, 18))
ggplot(DF, aes(Name, Values)) + geom_col(fill = "skyblue") +
geom_text(aes(label = Values, vjust = 1)) +
theme(axis.text.x = element_text(angle = 90, hjust = 0.5, vjust = 0.5))
Created on 2020-01-21 by the reprex package (v0.3.0)
Thank you very much, your answer is what I needed
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.