
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "gallery/misc/keyword_plotting.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. meta::
        :keywords: codex

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_gallery_misc_keyword_plotting.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_gallery_misc_keyword_plotting.py:


======================
Plotting with keywords
======================

Some data structures, like dict, `structured numpy array
<https://numpy.org/doc/stable/user/basics.rec.html#structured-arrays>`_
or `pandas.DataFrame` provide access to labelled data via string index access
``data[key]``.

For these data types, Matplotlib supports passing the whole datastructure via the
``data`` keyword argument, and using the string names as plot function parameters,
where you'd normally pass in your data.

.. GENERATED FROM PYTHON SOURCE LINES 15-31



.. image-sg:: /gallery/misc/images/sphx_glr_keyword_plotting_001.png
   :alt: keyword plotting
   :srcset: /gallery/misc/images/sphx_glr_keyword_plotting_001.png, /gallery/misc/images/sphx_glr_keyword_plotting_001_2_00x.png 2.00x
   :class: sphx-glr-single-img





.. code-block:: Python


    import matplotlib.pyplot as plt
    import numpy as np

    np.random.seed(19680801)

    data = {'a': np.arange(50),
            'c': np.random.randint(0, 50, 50),
            'd': np.random.randn(50)}
    data['b'] = data['a'] + 10 * np.random.randn(50)
    data['d'] = np.abs(data['d']) * 100

    fig, ax = plt.subplots()
    ax.scatter('a', 'b', c='c', s='d', data=data)
    ax.set(xlabel='entry a', ylabel='entry b')
    plt.show()


.. _sphx_glr_download_gallery_misc_keyword_plotting.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

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

    .. container:: sphx-glr-download sphx-glr-download-python

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

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: keyword_plotting.zip <keyword_plotting.zip>`


.. only:: html

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

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
