matplotlib

Previous topic

pylab_examples example code: line_collection2.py

Next topic

pylab_examples example code: loadrec.py

This Page

pylab_examples example code: load_converter.pyΒΆ

(Source code, png)

../../_images/load_converter.png
from __future__ import print_function
from matplotlib.dates import strpdate2num
#from matplotlib.mlab import load
import numpy as np
from pylab import figure, show
import matplotlib.cbook as cbook

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

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

fig = figure()
ax = fig.add_subplot(111)
ax.plot_date(dates, closes, '-')
fig.autofmt_xdate()
show()

Keywords: python, matplotlib, pylab, example, codex (see Search examples)