0

I have subplots with shared x,y axis. The x-axis is datetime stamp. Everything looks fine. The problem is x-axis looks clumsy.

My code:

fig, ax = plt.subplots(nrows=rows, ncols=cols,sharey=True,sharex=True)
fig.subplots_adjust(hspace=0.025, wspace=0.05)
for i in range(rows):
    for j in range(cols):
        #### plot data goes here. 
        ax[i,j].autofmt_xdate()
        ax[i,j].xaxis.set_tick_params(rotation = 30)
fig.subplots_adjust(right=0.95)
plt.show()

Present output: The x-axis labels look clumsy, hard to read.

enter image description here

Mainland
  • 4,110
  • 3
  • 25
  • 56
  • First make sure your dates are not strings. You can rotate the text as per the link above. You can also use ConciseDateFormatter https://matplotlib.org/3.1.0/gallery/ticks_and_spines/date_concise_formatter.html – Jody Klymak Oct 05 '20 at 16:32
  • @JodyKlymak Yes! My dates are indeed in `dtype='datetime64[ns]'` format, not string. Also, I edited my question. Now, the labels are rotated. I need to reduce their frequency. – Mainland Oct 05 '20 at 16:38
  • 1
    Your plot is too small while you try to force the dates as xticks. try passing `figsize=(20,10)` to subplots. – Quang Hoang Oct 05 '20 at 17:31
  • You are right. I played with the size. It solved the issue. Thanks – Mainland Oct 05 '20 at 18:06

0 Answers0