+ + +
+
+ +
+
+ +
+ +
+ + + + +
+ +
+ + +
+
+ + + + + +
+ + +
+
+
+

Petroff Color Sequence#

+

The Petroff color sequence is a visually appealing color scheme in Matplotlib designed for clarity in data visualizations. It smoothly transitions between colors, making it ideal for graphs where clear distinctions between data points are necessary, like line plots or bar charts.

+ +

To use the Petroff color sequence in Matplotlib, simply reference it by its name, 'petroff10', when setting the colormap in your plots.

+ +

To add or remove color sequences in Matplotlib, you can use the ColorSequenceRegistry class's register and unregister functions. The register function allows you to add a custom color sequence by specifying a unique name and a list of colors. Once registered, the color sequence can be accessed by name in Matplotlib.

+ +

Here’s a code snippet demonstrating how to register and unregister a color sequence:

+ +

+      import matplotlib as mpl
+      
+      # Register a new color sequence
+      mpl.color_sequences.register('my_sequence', ['#FF0000', '#00FF00', '#0000FF'])
+      
+      # Access the newly registered color sequence
+      cmap = mpl.color_sequences['my_sequence']
+      print(cmap)  # Outputs: ['#FF0000', '#00FF00', '#0000FF']
+      
+      # Unregister the custom color sequence
+      mpl.color_sequences.unregister('my_sequence')
+        
+ +

This code snippet demonstrates how to create, access, and remove custom color sequences. Note that built-in color sequences like 'petroff10' cannot be unregistered as they are predefined by Matplotlib.

+ +

For more details on color sequences and effective color choices, you can view Colin Ware's study on color sequences here.

+
+ + + + + + + + + + + + +
+ +
+ +