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

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

.. _sphx_glr_gallery_color_color_cycle_default.py:


====================================
Colors in the default property cycle
====================================

Display the colors from the default prop_cycle, which is obtained from the
:ref:`rc parameters<customizing>`.

.. GENERATED FROM PYTHON SOURCE LINES 9-37

.. code-block:: Python

    import matplotlib.pyplot as plt
    import numpy as np

    from matplotlib.colors import TABLEAU_COLORS, same_color


    def f(x, a):
        """A nice sigmoid-like parametrized curve, ending approximately at *a*."""
        return 0.85 * a * (1 / (1 + np.exp(-x)) + 0.2)


    fig, ax = plt.subplots()
    ax.axis('off')
    ax.set_title("Colors in the default property cycle")

    prop_cycle = plt.rcParams['axes.prop_cycle']
    colors = prop_cycle.by_key()['color']
    x = np.linspace(-4, 4, 200)

    for i, (color, color_name) in enumerate(zip(colors, TABLEAU_COLORS)):
        assert same_color(color, color_name)
        pos = 4.5 - i
        ax.plot(x, f(x, pos))
        ax.text(4.2, pos, f"'C{i}': '{color_name}'", color=color, va="center")
        ax.bar(9, 1, width=1.5, bottom=pos-0.5)

    plt.show()




.. image-sg:: /gallery/color/images/sphx_glr_color_cycle_default_001.png
   :alt: Colors in the default property cycle
   :srcset: /gallery/color/images/sphx_glr_color_cycle_default_001.png, /gallery/color/images/sphx_glr_color_cycle_default_001_2_00x.png 2.00x
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 38-54

.. admonition:: References

   The use of the following functions, methods, classes and modules is shown
   in this example:

   - `matplotlib.axes.Axes.axis`
   - `matplotlib.axes.Axes.text`
   - `matplotlib.colors.same_color`
   - `cycler.Cycler`

.. tags::

   styling: color
   purpose: reference
   plot-type: line
   level: beginner


.. _sphx_glr_download_gallery_color_color_cycle_default.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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