I am looking for a way to write the labels of my plot, which has been flipped using coord_flip()
, next to bars of the plot. Reproducible example:
Names <- c("ExampleA","ExampleB","ExampleC","ExampleD", "ExampleE", "ExampleF","ExampleG", "ExampleH")
Counts <- c(4,3,2,1,-1,-2,-3,-4)
Type <- c("X","X","X","X", "Y","Y","Y","Y")
df <-data.frame(Names,Counts, Type)
ggplot(df, aes(x=reorder(Names,Counts), y=Counts, fill=Type))+
geom_col()+
coord_flip()+
theme_minimal()
I need to write the labels of the plot (Names
) next to the bars. I’ve tried geom_label
with parse=TRUE
and scale_x_discrete
with position="inside"
, but neither has worked.
Do you know of any other way to achieve my goal?