I'm making a bargraph in ggplot2, and for presentation reasons I need spaces between some of my bars. I'm using limits in scale_x_discrete
to insert empty bars, which gives me the spacing I need.
The gap between groups b
and c
in my mock data looks perfect, but the gap between a
and b
still has the black tick mark and the white line in the background. I don't need any x axis gridlines, so I can fix the problem of the white line easily enough, but I can't work out how to get rid of the tick mark.
I'm using R version 3.3.1 (2016-06-21) -- "Bug in Your Hair", working in RStudio and the code requires ggplot2
### Mock data with the same structure as mine
my.data <- data.frame(x = rep(c("a", "b", "c", "d"), 3),
y = c("e", "f", "g"))
### Make graph
ggplot(my.data, aes(x = x, fill = y)) +
geom_bar(position = "fill") +
scale_x_discrete(limits = c("a", "", "b", "", "c", "d"))
### Remove white line in background by removing all x grid lines
ggplot (my.data, aes(x = x, fill = y)) +
geom_bar(position = "fill") +
scale_x_discrete(limits = c("a", "", "b", "", "c", "d")) +
theme(panel.grid.minor.x = element_blank(),
panel.grid.major.x = element_blank())
How do I remove the black tick mark between a
and b
?
If I need to change the way I'm inserting spaces between bars, how do I do that and maintain the graph structure?