# Best option for time series with Python matplotlib

Learn the Secret

GetÂ  our 2 Free Books

Get these now which land directly to their inbox.
(Last Updated On: January 12, 2016)

Best option for time series with Python matplotlib

There are 3 coding samples below which demo auto scaling for dates in Python’s MatPlotLib. Best one appears to be the last one.

Sourced links are listed as well

Join my FREE newsletter to learn how I use these coding samples for automated trading in Python

```#http://stackoverflow.com/questions/29461608/matplotlib-fixing-x-axis-scale-and-autoscale-y-axis

# import numpy as np
# import matplotlib.pyplot as plt
#
# x, y = np.arange(0,101,1) ,300 - 0.1*np.arange(0,101,1)
# mask = (x >= 50) & (x <= 100)
#
# fig, ax = plt.subplots()
#
# plt.show()

#http://stackoverflow.com/questions/32972371/how-to-show-date-and-time-on-x-axis-in-matplotlib
# import matplotlib.pyplot as plt
# import pandas as pd
# import matplotlib.dates as mdates
#
# times = pd.date_range('2015-10-06', periods=500, freq='10min')
#
# fig, ax = plt.subplots(1)
# fig.autofmt_xdate()
# plt.plot(times, range(times.size))
#
# xfmt = mdates.DateFormatter('%d-%m-%y %H:%M')
# ax.xaxis.set_major_formatter(xfmt)
#
# plt.show()

#this one works best and easiest it seems
#http://blog.mafr.de/2012/03/11/time-series-data-with-matplotlib/
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as mdates