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 9159096

Browse filesBrowse files
committed
Add example of petroff10
1 parent 5461ae2 commit 9159096
Copy full SHA for 9159096

File tree

Expand file treeCollapse file tree

1 file changed

+43
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+43
-0
lines changed
+43Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""
2+
=====================
3+
Petroff10 style sheet
4+
=====================
5+
6+
This example demonstrates the "petroff10" style, which implements the 10-color
7+
sequence developed by Matthew A. Petroff [1]_ for accessible data visualization.
8+
The style balances aesthetics with accessibility considerations, making it
9+
suitable for various types of plots while ensuring readability and distinction
10+
between data series.
11+
12+
.. [1] https://arxiv.org/abs/2107.02270
13+
14+
"""
15+
16+
import matplotlib.pyplot as plt
17+
import numpy as np
18+
19+
20+
def colored_lines_example(ax):
21+
t = np.linspace(-10, 10, 100)
22+
nb_colors = len(plt.rcParams['axes.prop_cycle'])
23+
shifts = np.linspace(-5, 5, nb_colors)
24+
amplitudes = np.linspace(1, 1.5, nb_colors)
25+
for t0, a in zip(shifts, amplitudes):
26+
y = a / (1 + np.exp(-(t - t0)))
27+
line, = ax.plot(t, y, '-')
28+
point_indices = np.linspace(0, len(t) - 1, 20, dtype=int)
29+
ax.plot(t[point_indices], y[point_indices], 'o', color=line.get_color())
30+
ax.set_xlim(-10, 10)
31+
32+
33+
def image_and_patch_example(ax):
34+
ax.imshow(np.random.random(size=(20, 20)), interpolation='none')
35+
c = plt.Circle((5, 5), radius=5, label='patch')
36+
ax.add_patch(c)
37+
38+
plt.style.use('petroff10')
39+
fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=(12, 5))
40+
fig.suptitle("'petroff10' style sheet")
41+
colored_lines_example(ax1)
42+
image_and_patch_example(ax2)
43+
plt.show()

0 commit comments

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