

.. _sphx_glr_gallery_pylab_examples_load_converter.py:


==============
Load Converter
==============





.. image:: /gallery/pylab_examples/images/sphx_glr_load_converter_001.png
    :align: center


.. rst-class:: sphx-glr-script-out

 Out::

    loading /home/elliott/code/matplotlib/lib/matplotlib/mpl-data/sample_data/msft.csv




|


.. code-block:: python

    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 = plt.figure()
    ax = fig.add_subplot(111)
    ax.plot_date(dates, closes, '-')
    fig.autofmt_xdate()
    plt.show()

**Total running time of the script:** ( 0 minutes  0.081 seconds)



.. container:: sphx-glr-footer


  .. container:: sphx-glr-download

     :download:`Download Python source code: load_converter.py <load_converter.py>`



  .. container:: sphx-glr-download

     :download:`Download Jupyter notebook: load_converter.ipynb <load_converter.ipynb>`

.. rst-class:: sphx-glr-signature

    `Generated by Sphinx-Gallery <https://sphinx-gallery.readthedocs.io>`_
