Color Matrix

original, grayscale, sepia, nightvision, warm, cool
/home/docs/checkouts/readthedocs.org/user_builds/mpl-visual-context/checkouts/no_contour/examples/path_effects/test_color_matrix.py:33: FutureWarning:

Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `y` variable to `hue` and set `legend=False` for the same effect.

  sns.countplot(y="species", data=df_peng, ax=ax, palette="Blues")
/home/docs/checkouts/readthedocs.org/user_builds/mpl-visual-context/checkouts/no_contour/examples/path_effects/test_color_matrix.py:33: FutureWarning:

Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `y` variable to `hue` and set `legend=False` for the same effect.

  sns.countplot(y="species", data=df_peng, ax=ax, palette="Blues")
/home/docs/checkouts/readthedocs.org/user_builds/mpl-visual-context/checkouts/no_contour/examples/path_effects/test_color_matrix.py:33: FutureWarning:

Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `y` variable to `hue` and set `legend=False` for the same effect.

  sns.countplot(y="species", data=df_peng, ax=ax, palette="Blues")
/home/docs/checkouts/readthedocs.org/user_builds/mpl-visual-context/checkouts/no_contour/examples/path_effects/test_color_matrix.py:33: FutureWarning:

Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `y` variable to `hue` and set `legend=False` for the same effect.

  sns.countplot(y="species", data=df_peng, ax=ax, palette="Blues")
/home/docs/checkouts/readthedocs.org/user_builds/mpl-visual-context/checkouts/no_contour/examples/path_effects/test_color_matrix.py:33: FutureWarning:

Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `y` variable to `hue` and set `legend=False` for the same effect.

  sns.countplot(y="species", data=df_peng, ax=ax, palette="Blues")
/home/docs/checkouts/readthedocs.org/user_builds/mpl-visual-context/checkouts/no_contour/examples/path_effects/test_color_matrix.py:33: FutureWarning:

Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `y` variable to `hue` and set `legend=False` for the same effect.

  sns.countplot(y="species", data=df_peng, ax=ax, palette="Blues")

import matplotlib.pyplot as plt
import seaborn as sns

# sns.color_palette("rocket")

from matplotlib.gridspec import GridSpec
from mpl_visual_context.patheffects import ColorMatrix as CM


def main():
    df_peng = sns.load_dataset("penguins")

    color_matrix = CM.color_matrix

    pe_list = [("original", [])] + [(k, [CM(k)]) for k in color_matrix]

    nn = len(pe_list)
    ncol = 3
    nrow = (nn - 1) // ncol + 1

    fig = plt.figure(figsize=(3 * ncol, 2 * nrow), layout="constrained")
    gs = GridSpec(nrow, ncol, figure=fig)

    for gs1, (k, pe) in zip(gs, pe_list):
        ax = fig.add_subplot(gs1)

        sns.countplot(y="species", data=df_peng, ax=ax, palette="Blues")
        ax.set_title(k)

        for p in ax.patches:
            p.set_path_effects(pe)

    plt.show()


if __name__ == '__main__':
    main()

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

Gallery generated by Sphinx-Gallery