diff --git a/doc/index.rst b/doc/index.rst index dedd614985df..b91b83b76df9 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -175,3 +175,80 @@ About us :maxdepth: 2 project/index.rst + +.. _color-sequences: + +Color Sequences in Matplotlib +============================= + +Matplotlib provides a powerful system for defining custom color sequences, + or color cycles, which are essential for creating consistent, visually appealing plots. + By customizing color sequences, users can control the color schemes used in their plots to improve accessibility and + make their visualizations clearer. + +What Are Color Sequences? +-------------------------- + +In Matplotlib, color sequences are essentially ordered lists of colors +that can be used across multiple plots. They allow for consistency in the colors used + for different lines, markers, and other visual elements in your plots. Color sequences can be customized and applied through the `cycler` module or in style sheets. + +Defining a Custom Color Cycle +------------------------------ + +To define a custom color cycle, we use the `cycler` module +from Matplotlib. Here's how to define and apply your own color sequence: + +.. code-block:: python + + import matplotlib.pyplot as plt + from cycler import cycler + + # Define a custom color cycle + custom_cycle = cycler(color=["#E63946", "#F4A261", "#2A9D8F", "#264653"]) + + # Apply the custom color cycle + plt.rc("axes", prop_cycle=custom_cycle) + + # Create a simple plot to visualize the color sequence + fig, ax = plt.subplots() + ax.plot([1, 2, 3], [4, 5, 6], label="Line 1") + ax.plot([1, 2, 3], [6, 7, 8], label="Line 2") + ax.legend() + plt.show() + +Using Color Sequences in Style Sheets +-------------------------------------- + +You can also apply custom color sequences by defining them in a + Matplotlib style sheet (`.mplstyle` file). This is especially useful if you want to + keep your color settings consistent across different projects. + +Here's how you can define a custom color cycle in a style sheet: + +.. code-block:: plaintext + + axes.prop_cycle: cycler(color=["#E63946", "#F4A261", "#2A9D8F", "#264653"]) + +Benefits of Using Custom Color Sequences +----------------------------------------- + +Custom color sequences are beneficial for several reasons: + +- **Consistency**: They ensure that your plots have a uniform color +scheme across multiple figures. +- **Accessibility**: By using colorblind-friendly colors, you can make your + visualizations more accessible to a wider audience. +- **Aesthetics**: Custom color sequences allow you to create more visually appealing + plots that match your preferred style or brand. + +Conclusion +---------- + +Color sequences are a powerful tool in Matplotlib for customizing the appearance of your plots. + By defining your own color cycles and using them consistently, you can create more accessible and + aesthetically pleasing visualizations. + Experiment with your own color sequences and see how they improve your plots. + +For more information on colormaps and color customization, +check out the [colormap tutorial](https://matplotlib.org/stable/tutorials/colors/colormap.html). \ No newline at end of file diff --git a/doc/users/doc/users/explain/colors/index.rst b/doc/users/doc/users/explain/colors/index.rst new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/matplotlib b/matplotlib new file mode 160000 index 000000000000..e081c7e66a73 --- /dev/null +++ b/matplotlib @@ -0,0 +1 @@ +Subproject commit e081c7e66a732d36df26e00091d36a86e72da003