|
| 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