I have a categorical axis where i\'d like to visually separate groups within that categorical variable. I don\'t want to facet because it takes up too much space and is visu
You can get the result you are looking for via the breaks
and limits
arguments to scale_x_discrete
. Set the breaks
to the levels of the factor on the x-axis and the limits
to the factor levels with spacers were you want/need them.
Here is an example:
library(ggplot2)
dd <- data.frame(x = factor(letters[1:10]), y = 1:10)
ggplot(dd) +
aes(x = x, y = y) +
geom_point() +
scale_x_discrete(breaks = levels(dd$x),
limits = c(levels(dd$x)[1], "skip", levels(dd$x)[-1]))