|
| 1 | +""" |
| 2 | +Display the colors from the default prop_cycle. |
| 3 | +""" |
| 4 | + |
| 5 | +import numpy as np |
| 6 | +import matplotlib.pyplot as plt |
| 7 | + |
| 8 | +prop_cycle = plt.rcParams['axes.prop_cycle'] |
| 9 | +colors = prop_cycle.by_key()['color'] |
| 10 | + |
| 11 | +lwbase = plt.rcParams['lines.linewidth'] |
| 12 | +thin = float('%.1f' % (lwbase / 2)) |
| 13 | +thick = lwbase * 3 |
| 14 | + |
| 15 | +fig, axs = plt.subplots(nrows=2, ncols=2, sharex=True, sharey=True) |
| 16 | +for icol in range(2): |
| 17 | + if icol == 0: |
| 18 | + lwx, lwy = thin, lwbase |
| 19 | + else: |
| 20 | + lwx, lwy = lwbase, thick |
| 21 | + for irow in range(2): |
| 22 | + for i, color in enumerate(colors): |
| 23 | + axs[irow, icol].axhline(i, color=color, lw=lwx) |
| 24 | + axs[irow, icol].axvline(i, color=color, lw=lwy) |
| 25 | + |
| 26 | + axs[1, icol].set_facecolor('k') |
| 27 | + axs[1, icol].xaxis.set_ticks(np.arange(0, 10, 2)) |
| 28 | + axs[0, icol].set_title('line widths (pts): %.1f, %.1f' % (lwx, lwy), |
| 29 | + fontsize='medium') |
| 30 | + |
| 31 | +for irow in range(2): |
| 32 | + axs[irow, 0].yaxis.set_ticks(np.arange(0, 10, 2)) |
| 33 | + |
| 34 | +fig.suptitle('Colors in the default prop_cycle', fontsize='large') |
| 35 | + |
| 36 | +plt.show() |
0 commit comments