From e06ebbdad4ef180e211b5da1ebe132450acd9ea1 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sun, 3 Mar 2024 15:37:57 -0500 Subject: [PATCH 1/4] Add ten-color accessible color cycle as style sheet. Color cycle survey palette from Petroff (2021): https://arxiv.org/abs/2107.02270 https://github.com/mpetroff/accessible-color-cycles --- doc/users/next_whats_new/ccs_color_cycle.rst | 19 +++++++++++++++++++ .../mpl-data/stylelib/ccs10.mplstyle | 5 +++++ 2 files changed, 24 insertions(+) create mode 100644 doc/users/next_whats_new/ccs_color_cycle.rst create mode 100644 lib/matplotlib/mpl-data/stylelib/ccs10.mplstyle diff --git a/doc/users/next_whats_new/ccs_color_cycle.rst b/doc/users/next_whats_new/ccs_color_cycle.rst new file mode 100644 index 000000000000..d10562919278 --- /dev/null +++ b/doc/users/next_whats_new/ccs_color_cycle.rst @@ -0,0 +1,19 @@ +New more-accessible color cycle +------------------------------- + +A new color cycle named 'ccs10' was added. This cycle was constructed using a +combination of algorithmically-enforced accessibility constraints, including +color-vision-deficiency modeling, and a machine-learning-based aesthetics model +developed from a crowdsourced color-preference survey. It aims to be both +generally pleasing aesthetically and colorblind accessible such that it could +serve as a default in the aim of universal design. For more details +see `Petroff, M. A.: "Accessible Color Sequences for Data Visualization" +`_ and related `SciPy talk`_. A demonstration +is included in the style sheets reference_. To load this color cycle in place +of the default:: + + import matplotlib.pyplot as plt + plt.style.use('ccs10') + +.. _reference: https://matplotlib.org/gallery/style_sheets/style_sheets_reference.html +.. _SciPy talk: https://www.youtube.com/watch?v=Gapv8wR5DYU diff --git a/lib/matplotlib/mpl-data/stylelib/ccs10.mplstyle b/lib/matplotlib/mpl-data/stylelib/ccs10.mplstyle new file mode 100644 index 000000000000..62d1262a09cd --- /dev/null +++ b/lib/matplotlib/mpl-data/stylelib/ccs10.mplstyle @@ -0,0 +1,5 @@ +# Color cycle survey palette from Petroff (2021): +# https://arxiv.org/abs/2107.02270 +# https://github.com/mpetroff/accessible-color-cycles +axes.prop_cycle: cycler('color', ['3f90da', 'ffa90e', 'bd1f01', '94a4a2', '832db6', 'a96b59', 'e76300', 'b9ac70', '717581', '92dadd']) +patch.facecolor: 3f90da From 44a4abaa414b4d0867f8aa0defd6a388b77c6f5f Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Fri, 16 Aug 2024 16:21:58 -0400 Subject: [PATCH 2/4] MNT: rename style See discussion in https://github.com/mpetroff/accessible-color-cycles/issues/1 Co-authored-by: Matthew Feickert --- doc/users/next_whats_new/ccs_color_cycle.rst | 4 ++-- .../mpl-data/stylelib/{ccs10.mplstyle => petroff10.mplstyle} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename lib/matplotlib/mpl-data/stylelib/{ccs10.mplstyle => petroff10.mplstyle} (100%) diff --git a/doc/users/next_whats_new/ccs_color_cycle.rst b/doc/users/next_whats_new/ccs_color_cycle.rst index d10562919278..2c9c0c85145c 100644 --- a/doc/users/next_whats_new/ccs_color_cycle.rst +++ b/doc/users/next_whats_new/ccs_color_cycle.rst @@ -1,7 +1,7 @@ New more-accessible color cycle ------------------------------- -A new color cycle named 'ccs10' was added. This cycle was constructed using a +A new color cycle named 'petroff10' was added. This cycle was constructed using a combination of algorithmically-enforced accessibility constraints, including color-vision-deficiency modeling, and a machine-learning-based aesthetics model developed from a crowdsourced color-preference survey. It aims to be both @@ -13,7 +13,7 @@ is included in the style sheets reference_. To load this color cycle in place of the default:: import matplotlib.pyplot as plt - plt.style.use('ccs10') + plt.style.use('petroff10') .. _reference: https://matplotlib.org/gallery/style_sheets/style_sheets_reference.html .. _SciPy talk: https://www.youtube.com/watch?v=Gapv8wR5DYU diff --git a/lib/matplotlib/mpl-data/stylelib/ccs10.mplstyle b/lib/matplotlib/mpl-data/stylelib/petroff10.mplstyle similarity index 100% rename from lib/matplotlib/mpl-data/stylelib/ccs10.mplstyle rename to lib/matplotlib/mpl-data/stylelib/petroff10.mplstyle From ff584d790e2fcb217cad5e363e0291d036ea1713 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Fri, 16 Aug 2024 16:38:12 -0400 Subject: [PATCH 3/4] ENH: add petroff10 to the sequence registry --- lib/matplotlib/_cm.py | 14 ++++++++++++++ lib/matplotlib/colors.py | 1 + 2 files changed, 15 insertions(+) diff --git a/lib/matplotlib/_cm.py b/lib/matplotlib/_cm.py index 59d260107f3b..b942d1697934 100644 --- a/lib/matplotlib/_cm.py +++ b/lib/matplotlib/_cm.py @@ -1366,6 +1366,20 @@ def _gist_yarg(x): return 1 - x ) +_petroff10_data = ( + (0.24705882352941178, 0.5647058823529412, 0.8549019607843137), # 3f90da + (1.0, 0.6627450980392157, 0.054901960784313725), # ffa90e + (0.7411764705882353, 0.12156862745098039, 0.00392156862745098), # bd1f01 + (0.5803921568627451, 0.6431372549019608, 0.6352941176470588), # 94a4a2 + (0.5137254901960784, 0.17647058823529413, 0.7137254901960784), # 832db6 + (0.6627450980392157, 0.4196078431372549, 0.34901960784313724), # a96b59 + (0.9058823529411765, 0.38823529411764707, 0.0), # e76300 + (0.7254901960784313, 0.6745098039215687, 0.4392156862745098), # b9ac70 + (0.44313725490196076, 0.4588235294117647, 0.5058823529411764), # 717581 + (0.5725490196078431, 0.8549019607843137, 0.8666666666666667), # 92dadd +) + + datad = { 'Blues': _Blues_data, 'BrBG': _BrBG_data, diff --git a/lib/matplotlib/colors.py b/lib/matplotlib/colors.py index 5f40e7b0fb9a..7c127fce7819 100644 --- a/lib/matplotlib/colors.py +++ b/lib/matplotlib/colors.py @@ -129,6 +129,7 @@ class ColorSequenceRegistry(Mapping): 'Set1': _cm._Set1_data, 'Set2': _cm._Set2_data, 'Set3': _cm._Set3_data, + 'petroff10': _cm._petroff10_data, } def __init__(self): From 055ad6e22ce5c75b5da7e05edd81911cd4948912 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sun, 18 Aug 2024 16:38:26 -0400 Subject: [PATCH 4/4] MNT: Update test to match sequence registry. --- lib/matplotlib/tests/test_colors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_colors.py b/lib/matplotlib/tests/test_colors.py index d99dd91e9cf5..3fd7cbdc9d46 100644 --- a/lib/matplotlib/tests/test_colors.py +++ b/lib/matplotlib/tests/test_colors.py @@ -1634,7 +1634,7 @@ def test_color_sequences(): assert plt.color_sequences is matplotlib.color_sequences # same registry assert list(plt.color_sequences) == [ 'tab10', 'tab20', 'tab20b', 'tab20c', 'Pastel1', 'Pastel2', 'Paired', - 'Accent', 'Dark2', 'Set1', 'Set2', 'Set3'] + 'Accent', 'Dark2', 'Set1', 'Set2', 'Set3', 'petroff10'] assert len(plt.color_sequences['tab10']) == 10 assert len(plt.color_sequences['tab20']) == 20 pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy