You are reading an old version of the documentation (v2.2.4). For the latest version see https://matplotlib.org/stable/
Version 2.2.4
matplotlib
Fork me on GitHub

Related Topics

Load ConverterΒΆ

../../_images/sphx_glr_load_converter_001.png

Out:

loading /home/tcaswell/.virtualenvs/sys37/lib/python3.7/site-packages/matplotlib/mpl-data/sample_data/msft.csv

from __future__ import print_function
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cbook as cbook
import matplotlib.dates as mdates
from matplotlib.dates import bytespdate2num

datafile = cbook.get_sample_data('msft.csv', asfileobj=False)
print('loading', datafile)

dates, closes = np.loadtxt(datafile, delimiter=',',
                           converters={0: bytespdate2num('%d-%b-%y')},
                           skiprows=1, usecols=(0, 2), unpack=True)

fig, ax = plt.subplots()
ax.plot_date(dates, closes, '-')
fig.autofmt_xdate()
plt.show()

Keywords: matplotlib code example, codex, python plot, pyplot Gallery generated by Sphinx-Gallery