Reputation: 427
I have a ggplot which looks like this.
p2=ggplot(data=data1, aes(x=ID, y = value)) +
geom_line(group=1,color='steelblue', size=2) + facet_wrap(~variable)+theme_economist()
p2=p2+theme(text = element_text(size=10), axis.text.x = element_text(angle=90, hjust=1))
p2
The issue is that, I am getting overlapping X labels in the X axis. Is there any way to get non overlapping X axis labels.
Upvotes: 4
Views: 19219
Reputation: 181
This will remove all labels which overlap:
scale_x_discrete(guide = guide_axis(check.overlap = TRUE))
Upvotes: 0
Reputation: 129
There is nice solution to this problem with ggplot2 version 3.3.0.
scale_x_discrete(guide = guide_axis(n.dodge=3))
Here is an example
Upvotes: 7
Reputation: 1277
Try + coord_flip()
-- the labels might fit better and be more legible on the y-axis.
Upvotes: 2