Python Matplotlib: How To Reduce Number Of X Tick Marks For Non-numeric Tyoe
I have this very simple pandas dataframe here and i'm trying to plot the index column (Date, which is formatted as string) against 'Adj Close' Column. Adj Close
Solution 1:
You can sample your ticks and set the list as your new ticks.
# current x labels
current_ticks = ax.get_xticklabels()
# resampling every other label, change mod(2) to sample less
custom_ticks = [a.get_text() for a in current_ticks if current_ticks.index(a)%2]
# set as new labels
ax.set_xticks(custom_ticks)
ax.set_xticklabels(custom_ticks)
Post a Comment for "Python Matplotlib: How To Reduce Number Of X Tick Marks For Non-numeric Tyoe"