{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Petroff10 style sheet\n\nThis example demonstrates the \"petroff10\" style, which implements the 10-color\nsequence developed by Matthew A. Petroff [1]_ for accessible data visualization.\nThe style balances aesthetics with accessibility considerations, making it\nsuitable for various types of plots while ensuring readability and distinction\nbetween data series.\n\n.. [1] https://arxiv.org/abs/2107.02270\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\nimport numpy as np\n\n\ndef colored_lines_example(ax):\n t = np.linspace(-10, 10, 100)\n nb_colors = len(plt.rcParams['axes.prop_cycle'])\n shifts = np.linspace(-5, 5, nb_colors)\n amplitudes = np.linspace(1, 1.5, nb_colors)\n for t0, a in zip(shifts, amplitudes):\n y = a / (1 + np.exp(-(t - t0)))\n line, = ax.plot(t, y, '-')\n point_indices = np.linspace(0, len(t) - 1, 20, dtype=int)\n ax.plot(t[point_indices], y[point_indices], 'o', color=line.get_color())\n ax.set_xlim(-10, 10)\n\n\ndef image_and_patch_example(ax):\n ax.imshow(np.random.random(size=(20, 20)), interpolation='none')\n c = plt.Circle((5, 5), radius=5, label='patch')\n ax.add_patch(c)\n\nplt.style.use('petroff10')\nfig, (ax1, ax2) = plt.subplots(ncols=2, figsize=(12, 5))\nfig.suptitle(\"'petroff10' style sheet\")\ncolored_lines_example(ax1)\nimage_and_patch_example(ax2)\nplt.show()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.2" } }, "nbformat": 4, "nbformat_minor": 0 }