Reputation: 476
Basically I would like to remove some of the vertical gridlines in my plot. Note that this is not a duplicate of How can I suppress the vertical gridlines in a ggplot2 plot? since this subjet is about deleting all the vertical gridlines.
Here is a minimal reproductible example :
ggplot(diamonds) +
aes(x = price) +
geom_histogram(
color = 'white',
fill = 'blue4'
) +
theme_minimal()
I would like to supress the vertical gridline which are not associated to a label (5000, 10000, ...).
I tried :
p +
theme(
panel.grid.major.x = element_blank()
)
but it actually does the opposite of what I'm looking for : It deletes the lines associated to a label, instead of the 'useless' ones.
Upvotes: 1
Views: 3798
Reputation: 389325
Try using panel.grid.minor.x
library(ggplot2)
ggplot(diamonds) +
aes(x = price) +
geom_histogram(
color = 'white',
fill = 'blue4'
) +
theme_minimal() +
theme(panel.grid.minor.x = element_blank())
Upvotes: 3