Skip to content

Instantly share code, notes, and snippets.

@razhangwei
Last active November 30, 2017 19:41
Show Gist options
  • Save razhangwei/ac274d140561c98a880e to your computer and use it in GitHub Desktop.
Save razhangwei/ac274d140561c98a880e to your computer and use it in GitHub Desktop.
Customize the styles of x-axis with dates. #Plotting
import matplotlib.dates as mdates
plot.hist(mdates.date2num(dts), 100) # plot the histogram
ax = plt.gca()
ax.xaxis.set_major_locator(mdates.AutoDateLocator()) # set the major ticker, use AutoDateLocator
ax.xaxis.set_major_formatter(mdates.DateFormatter('%m-%d')) # show the label
ax.xaxis.set_minor_locator(mdates.DayLocator()) # set the minor ticker, use DayLocator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment