
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "gallery/style_sheets/grayscale.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_style_sheets_grayscale.py>`
        to download the full example code.

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

.. _sphx_glr_gallery_style_sheets_grayscale.py:


=====================
Grayscale style sheet
=====================

This example demonstrates the "grayscale" style sheet, which changes all colors
that are defined as `.rcParams` to grayscale. Note, however, that not all
plot elements respect `.rcParams`.

.. GENERATED FROM PYTHON SOURCE LINES 10-42



.. image-sg:: /gallery/style_sheets/images/sphx_glr_grayscale_001.png
   :alt: 'grayscale' style sheet
   :srcset: /gallery/style_sheets/images/sphx_glr_grayscale_001.png, /gallery/style_sheets/images/sphx_glr_grayscale_001_2_00x.png 2.00x
   :class: sphx-glr-single-img





.. code-block:: Python


    import matplotlib.pyplot as plt
    import numpy as np

    # Fixing random state for reproducibility
    np.random.seed(19680801)


    def color_cycle_example(ax):
        L = 6
        x = np.linspace(0, L)
        ncolors = len(plt.rcParams['axes.prop_cycle'])
        shift = np.linspace(0, L, ncolors, endpoint=False)
        for s in shift:
            ax.plot(x, np.sin(x + s), 'o-')


    def image_and_patch_example(ax):
        ax.imshow(np.random.random(size=(20, 20)), interpolation='none')
        c = plt.Circle((5, 5), radius=5, label='patch')
        ax.add_patch(c)


    plt.style.use('grayscale')

    fig, (ax1, ax2) = plt.subplots(ncols=2)
    fig.suptitle("'grayscale' style sheet")

    color_cycle_example(ax1)
    image_and_patch_example(ax2)

    plt.show()


.. _sphx_glr_download_gallery_style_sheets_grayscale.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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