Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1056e0f

Browse filesBrowse files
authored
Merge pull request #27851 from mpetroff/add-ccs-color-cycle
Add ten-color accessible color cycle as style sheet
2 parents f58632f + 055ad6e commit 1056e0f
Copy full SHA for 1056e0f

File tree

Expand file treeCollapse file tree

5 files changed

+40
-1
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+40
-1
lines changed
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
New more-accessible color cycle
2+
-------------------------------
3+
4+
A new color cycle named 'petroff10' was added. This cycle was constructed using a
5+
combination of algorithmically-enforced accessibility constraints, including
6+
color-vision-deficiency modeling, and a machine-learning-based aesthetics model
7+
developed from a crowdsourced color-preference survey. It aims to be both
8+
generally pleasing aesthetically and colorblind accessible such that it could
9+
serve as a default in the aim of universal design. For more details
10+
see `Petroff, M. A.: "Accessible Color Sequences for Data Visualization"
11+
<https://arxiv.org/abs/2107.02270>`_ and related `SciPy talk`_. A demonstration
12+
is included in the style sheets reference_. To load this color cycle in place
13+
of the default::
14+
15+
import matplotlib.pyplot as plt
16+
plt.style.use('petroff10')
17+
18+
.. _reference: https://matplotlib.org/gallery/style_sheets/style_sheets_reference.html
19+
.. _SciPy talk: https://www.youtube.com/watch?v=Gapv8wR5DYU

‎lib/matplotlib/_cm.py

Copy file name to clipboardExpand all lines: lib/matplotlib/_cm.py
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,6 +1366,20 @@ def _gist_yarg(x): return 1 - x
13661366
)
13671367

13681368

1369+
_petroff10_data = (
1370+
(0.24705882352941178, 0.5647058823529412, 0.8549019607843137), # 3f90da
1371+
(1.0, 0.6627450980392157, 0.054901960784313725), # ffa90e
1372+
(0.7411764705882353, 0.12156862745098039, 0.00392156862745098), # bd1f01
1373+
(0.5803921568627451, 0.6431372549019608, 0.6352941176470588), # 94a4a2
1374+
(0.5137254901960784, 0.17647058823529413, 0.7137254901960784), # 832db6
1375+
(0.6627450980392157, 0.4196078431372549, 0.34901960784313724), # a96b59
1376+
(0.9058823529411765, 0.38823529411764707, 0.0), # e76300
1377+
(0.7254901960784313, 0.6745098039215687, 0.4392156862745098), # b9ac70
1378+
(0.44313725490196076, 0.4588235294117647, 0.5058823529411764), # 717581
1379+
(0.5725490196078431, 0.8549019607843137, 0.8666666666666667), # 92dadd
1380+
)
1381+
1382+
13691383
datad = {
13701384
'Blues': _Blues_data,
13711385
'BrBG': _BrBG_data,

‎lib/matplotlib/colors.py

Copy file name to clipboardExpand all lines: lib/matplotlib/colors.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ class ColorSequenceRegistry(Mapping):
129129
'Set1': _cm._Set1_data,
130130
'Set2': _cm._Set2_data,
131131
'Set3': _cm._Set3_data,
132+
'petroff10': _cm._petroff10_data,
132133
}
133134

134135
def __init__(self):
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Color cycle survey palette from Petroff (2021):
2+
# https://arxiv.org/abs/2107.02270
3+
# https://github.com/mpetroff/accessible-color-cycles
4+
axes.prop_cycle: cycler('color', ['3f90da', 'ffa90e', 'bd1f01', '94a4a2', '832db6', 'a96b59', 'e76300', 'b9ac70', '717581', '92dadd'])
5+
patch.facecolor: 3f90da

‎lib/matplotlib/tests/test_colors.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_colors.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1634,7 +1634,7 @@ def test_color_sequences():
16341634
assert plt.color_sequences is matplotlib.color_sequences # same registry
16351635
assert list(plt.color_sequences) == [
16361636
'tab10', 'tab20', 'tab20b', 'tab20c', 'Pastel1', 'Pastel2', 'Paired',
1637-
'Accent', 'Dark2', 'Set1', 'Set2', 'Set3']
1637+
'Accent', 'Dark2', 'Set1', 'Set2', 'Set3', 'petroff10']
16381638
assert len(plt.color_sequences['tab10']) == 10
16391639
assert len(plt.color_sequences['tab20']) == 20
16401640

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.