Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ggplot with overlapping X axis label [closed]

Tags:

r

ggplot2

I have a ggplot which looks like this.enter image description here

 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.

like image 608
Panchacookie Avatar asked Oct 21 '25 04:10

Panchacookie


1 Answers

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

like image 146
DataVizPyR Avatar answered Oct 25 '25 11:10

DataVizPyR



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!