G'day, I have a bunch of data which can be grouped. I want to display those data in a plot. Nothing special so far. But i have stumbled over the problem of displaying the data in a way, that signals their grouping. What i want is header for each section at the x-axis: so for Example the string "header 1" at the beginnen of the axis, "header 2" between A and B and so on. Here's the code i got so far
# packages
library (ggplot2)
# data
df = data.frame(
x = factor(c("A", "B", "C", "B", "A", "C")),
y = c(10, 15, 8, 12, 9, 10)
)
# Base plot
p <- ggplot(df, aes(x,y)) + geom_point() +
coord_flip()
p
There already exists a thread on a similar topic. Yet i would prefer a more "ggplot-y" way of doing so. Plus i would want the headers to be located directly at the x- axis.
Any help would be awesome, thanks