Last active
November 30, 2017 19:41
-
-
Save razhangwei/ac274d140561c98a880e to your computer and use it in GitHub Desktop.
Customize the styles of x-axis with dates. #Plotting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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