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

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

.. _sphx_glr_gallery_style_sheets_style_sheets_reference.py:


======================
Style sheets reference
======================

This script demonstrates the different available style sheets on a
common set of example plots: scatter plot, image, bar graph, patches,
line plot and histogram.

Any of these style sheets can be imported (i.e. activated) by its name.
For example for the ggplot style:

>>> plt.style.use('ggplot')

The names of the available style sheets can be found
in the list `matplotlib.style.available`
(they are also printed in the corner of each plot below).

See more details in :ref:`Customizing Matplotlib
using style sheets<customizing-with-style-sheets>`.

.. GENERATED FROM PYTHON SOURCE LINES 22-175



.. rst-class:: sphx-glr-horizontal


    *

      .. image-sg:: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_001.png
         :alt: default, Axes title, ax.grid(True)
         :srcset: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_001.png, /gallery/style_sheets/images/sphx_glr_style_sheets_reference_001_2_00x.png 2.00x
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_002.png
         :alt: classic, Axes title, ax.grid(True)
         :srcset: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_002.png, /gallery/style_sheets/images/sphx_glr_style_sheets_reference_002_2_00x.png 2.00x
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_003.png
         :alt: Solarize_Light2, Axes title, ax.grid(True)
         :srcset: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_003.png, /gallery/style_sheets/images/sphx_glr_style_sheets_reference_003_2_00x.png 2.00x
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_004.png
         :alt: bmh, Axes title, ax.grid(True)
         :srcset: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_004.png, /gallery/style_sheets/images/sphx_glr_style_sheets_reference_004_2_00x.png 2.00x
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_005.png
         :alt: dark_background, Axes title, ax.grid(True)
         :srcset: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_005.png, /gallery/style_sheets/images/sphx_glr_style_sheets_reference_005_2_00x.png 2.00x
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_006.png
         :alt: fast, Axes title, ax.grid(True)
         :srcset: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_006.png, /gallery/style_sheets/images/sphx_glr_style_sheets_reference_006_2_00x.png 2.00x
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_007.png
         :alt: fivethirtyeight, Axes title, ax.grid(True)
         :srcset: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_007.png, /gallery/style_sheets/images/sphx_glr_style_sheets_reference_007_2_00x.png 2.00x
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_008.png
         :alt: ggplot, Axes title, ax.grid(True)
         :srcset: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_008.png, /gallery/style_sheets/images/sphx_glr_style_sheets_reference_008_2_00x.png 2.00x
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_009.png
         :alt: grayscale, Axes title, ax.grid(True)
         :srcset: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_009.png, /gallery/style_sheets/images/sphx_glr_style_sheets_reference_009_2_00x.png 2.00x
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_010.png
         :alt: petroff10, Axes title, ax.grid(True)
         :srcset: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_010.png, /gallery/style_sheets/images/sphx_glr_style_sheets_reference_010_2_00x.png 2.00x
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_011.png
         :alt: seaborn-v0_8, Axes title, ax.grid(True)
         :srcset: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_011.png, /gallery/style_sheets/images/sphx_glr_style_sheets_reference_011_2_00x.png 2.00x
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_012.png
         :alt: seaborn-v0_8-bright, Axes title, ax.grid(True)
         :srcset: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_012.png, /gallery/style_sheets/images/sphx_glr_style_sheets_reference_012_2_00x.png 2.00x
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_013.png
         :alt: seaborn-v0_8-colorblind, Axes title, ax.grid(True)
         :srcset: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_013.png, /gallery/style_sheets/images/sphx_glr_style_sheets_reference_013_2_00x.png 2.00x
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_014.png
         :alt: seaborn-v0_8-dark, Axes title, ax.grid(True)
         :srcset: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_014.png, /gallery/style_sheets/images/sphx_glr_style_sheets_reference_014_2_00x.png 2.00x
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_015.png
         :alt: seaborn-v0_8-dark-palette, Axes title, ax.grid(True)
         :srcset: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_015.png, /gallery/style_sheets/images/sphx_glr_style_sheets_reference_015_2_00x.png 2.00x
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_016.png
         :alt: seaborn-v0_8-darkgrid, Axes title, ax.grid(True)
         :srcset: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_016.png, /gallery/style_sheets/images/sphx_glr_style_sheets_reference_016_2_00x.png 2.00x
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_017.png
         :alt: seaborn-v0_8-deep, Axes title, ax.grid(True)
         :srcset: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_017.png, /gallery/style_sheets/images/sphx_glr_style_sheets_reference_017_2_00x.png 2.00x
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_018.png
         :alt: seaborn-v0_8-muted, Axes title, ax.grid(True)
         :srcset: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_018.png, /gallery/style_sheets/images/sphx_glr_style_sheets_reference_018_2_00x.png 2.00x
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_019.png
         :alt: seaborn-v0_8-notebook, Axes title, ax.grid(True)
         :srcset: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_019.png, /gallery/style_sheets/images/sphx_glr_style_sheets_reference_019_2_00x.png 2.00x
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_020.png
         :alt: seaborn-v0_8-paper, Axes title, ax.grid(True)
         :srcset: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_020.png, /gallery/style_sheets/images/sphx_glr_style_sheets_reference_020_2_00x.png 2.00x
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_021.png
         :alt: seaborn-v0_8-pastel, Axes title, ax.grid(True)
         :srcset: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_021.png, /gallery/style_sheets/images/sphx_glr_style_sheets_reference_021_2_00x.png 2.00x
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_022.png
         :alt: seaborn-v0_8-poster, Axes title, ax.grid(True)
         :srcset: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_022.png, /gallery/style_sheets/images/sphx_glr_style_sheets_reference_022_2_00x.png 2.00x
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_023.png
         :alt: seaborn-v0_8-talk, Axes title, ax.grid(True)
         :srcset: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_023.png, /gallery/style_sheets/images/sphx_glr_style_sheets_reference_023_2_00x.png 2.00x
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_024.png
         :alt: seaborn-v0_8-ticks, Axes title, ax.grid(True)
         :srcset: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_024.png, /gallery/style_sheets/images/sphx_glr_style_sheets_reference_024_2_00x.png 2.00x
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_025.png
         :alt: seaborn-v0_8-white, Axes title, ax.grid(True)
         :srcset: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_025.png, /gallery/style_sheets/images/sphx_glr_style_sheets_reference_025_2_00x.png 2.00x
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_026.png
         :alt: seaborn-v0_8-whitegrid, Axes title, ax.grid(True)
         :srcset: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_026.png, /gallery/style_sheets/images/sphx_glr_style_sheets_reference_026_2_00x.png 2.00x
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_027.png
         :alt: tableau-colorblind10, Axes title, ax.grid(True)
         :srcset: /gallery/style_sheets/images/sphx_glr_style_sheets_reference_027.png, /gallery/style_sheets/images/sphx_glr_style_sheets_reference_027_2_00x.png 2.00x
         :class: sphx-glr-multi-img





.. code-block:: Python


    import matplotlib.pyplot as plt
    import numpy as np

    import matplotlib.colors as mcolors
    from matplotlib.patches import Rectangle

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


    def plot_scatter(ax, prng, nb_samples=100):
        """Scatter plot."""
        for mu, sigma, marker in [(-.5, 0.75, 'o'), (0.75, 1., 's')]:
            x, y = prng.normal(loc=mu, scale=sigma, size=(2, nb_samples))
            ax.plot(x, y, ls='none', marker=marker)
        ax.set_xlabel('X-label')
        ax.set_title('Axes title')
        return ax


    def plot_colored_lines(ax):
        """Plot lines with colors following the style color cycle."""
        t = np.linspace(-10, 10, 100)

        def sigmoid(t, t0):
            return 1 / (1 + np.exp(-(t - t0)))

        nb_colors = len(plt.rcParams['axes.prop_cycle'])
        shifts = np.linspace(-5, 5, nb_colors)
        amplitudes = np.linspace(1, 1.5, nb_colors)
        for t0, a in zip(shifts, amplitudes):
            ax.plot(t, a * sigmoid(t, t0), '-')
        ax.set_xlim(-10, 10)
        return ax


    def plot_bar_graphs(ax, prng, min_value=5, max_value=25, nb_samples=5):
        """Plot two bar graphs side by side, with letters as x-tick labels."""
        x = np.arange(nb_samples)
        ya, yb = prng.randint(min_value, max_value, size=(2, nb_samples))
        width = 0.25
        ax.bar(x, ya, width)
        ax.bar(x + width, yb, width, color='C2')
        ax.set_xticks(x + width, labels=['a', 'b', 'c', 'd', 'e'])
        return ax


    def plot_colored_circles(ax, prng, nb_samples=15):
        """
        Plot circle patches.

        NB: draws a fixed amount of samples, rather than using the length of
        the color cycle, because different styles may have different numbers
        of colors.
        """
        for sty_dict, j in zip(plt.rcParams['axes.prop_cycle'](),
                               range(nb_samples)):
            ax.add_patch(plt.Circle(prng.normal(scale=3, size=2),
                                    radius=1.0, color=sty_dict['color']))
        ax.grid(visible=True)

        # Add title for enabling grid
        plt.title('ax.grid(True)', family='monospace', fontsize='small')

        ax.set_xlim([-4, 8])
        ax.set_ylim([-5, 6])
        ax.set_aspect('equal', adjustable='box')  # to plot circles as circles
        return ax


    def plot_image_and_patch(ax, prng, size=(20, 20)):
        """Plot an image with random values and superimpose a circular patch."""
        values = prng.random_sample(size=size)
        ax.imshow(values, interpolation='none')
        c = plt.Circle((5, 5), radius=5, label='patch')
        ax.add_patch(c)
        # Remove ticks
        ax.set_xticks([])
        ax.set_yticks([])


    def plot_histograms(ax, prng, nb_samples=10000):
        """Plot 4 histograms and a text annotation."""
        params = ((10, 10), (4, 12), (50, 12), (6, 55))
        for a, b in params:
            values = prng.beta(a, b, size=nb_samples)
            ax.hist(values, histtype="stepfilled", bins=30,
                    alpha=0.8, density=True)

        # Add a small annotation.
        ax.annotate('Annotation', xy=(0.25, 4.25),
                    xytext=(0.9, 0.9), textcoords=ax.transAxes,
                    va="top", ha="right",
                    bbox=dict(boxstyle="round", alpha=0.2),
                    arrowprops=dict(
                              arrowstyle="->",
                              connectionstyle="angle,angleA=-95,angleB=35,rad=10"),
                    )
        return ax


    def plot_figure(style_label=""):
        """Setup and plot the demonstration figure with a given style."""
        # Use a dedicated RandomState instance to draw the same "random" values
        # across the different figures.
        prng = np.random.RandomState(96917002)

        fig, axs = plt.subplots(ncols=6, nrows=1, num=style_label,
                                figsize=(14.8, 2.8), layout='constrained')

        # make a suptitle, in the same style for all subfigures,
        # except those with dark backgrounds, which get a lighter color:
        background_color = mcolors.rgb_to_hsv(
            mcolors.to_rgb(plt.rcParams['figure.facecolor']))[2]
        if background_color < 0.5:
            title_color = [0.8, 0.8, 1]
        else:
            title_color = np.array([19, 6, 84]) / 256
        fig.suptitle(style_label, x=0.01, ha='left', color=title_color,
                     fontsize=14, fontfamily='DejaVu Sans', fontweight='normal')

        plot_scatter(axs[0], prng)
        plot_image_and_patch(axs[1], prng)
        plot_bar_graphs(axs[2], prng)
        plot_colored_lines(axs[3])
        plot_histograms(axs[4], prng)
        plot_colored_circles(axs[5], prng)

        # add divider
        rec = Rectangle((1 + 0.025, -2), 0.05, 16,
                        clip_on=False, color='gray')

        axs[4].add_artist(rec)

    if __name__ == "__main__":

        # Set up a list of all available styles, in alphabetical order but
        # the `default` and `classic` ones, which will be forced resp. in
        # first and second position.
        # styles with leading underscores are for internal use such as testing
        # and plot types gallery. These are excluded here.
        style_list = ['default', 'classic'] + sorted(
            style for style in plt.style.available
            if style != 'classic' and not style.startswith('_'))

        # Plot a demonstration figure for every available style sheet.
        for style_label in style_list:
            with plt.rc_context({"figure.max_open_warning": len(style_list)}):
                with plt.style.context(style_label):
                    plot_figure(style_label=style_label)

        plt.show()


.. rst-class:: sphx-glr-timing

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


.. _sphx_glr_download_gallery_style_sheets_style_sheets_reference.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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