I need to change x-axis ticks to be between sets of dodged bars in a ggplot barplot that has been rotated using coord flip.
This question has a solution that works brilliantly up to the point of coord_flip() How to plot x-axis labels and bars between tick marks in ggplot2 bar plot?
but then the code puts tick marks at the x(now Y) axis labels AS WELL as between the groups.... can anyone explain why and what to do about it....
ggplot(data, aes(x = x, y = value, fill = variable)) +
geom_col(position = "dodge") +
scale_x_continuous(breaks = c(sort(unique(data$x)), x_tick),
labels = c(sort(unique(data$name)), rep(c(""), len))) +
theme(axis.ticks.x = element_line(color = c(rep(NA, len -1), rep("black",len))))+coord_flip()

When using
coord_flipyou have to setaxis.ticks.yintheme:Or as a second option, get rid of
coord_flipby switchingxandyand settingorientation="y"ingeom_col: