Jul 09, 2026 — Digital Edition
George Ideas
Independent Journalism & Insight
Feature

Matplotlib Color Palette Codes

Matplotlib, a widely-used data visualization library in Python, offers a rich palette of colors to enhance the aesthetics and clarity of your plots. Understanding and effectively utilizing these color palettes can significantly improve the appeal and readability of your visualizations. Let's delve into the world of Matplotlib color palettes, exploring their types, how to use them, and some best practices.

there are four different colors on the waterlily with lily pads in the foreground
there are four different colors on the waterlily with lily pads in the foreground

Matplotlib provides a wide range of built-in color palettes, categorized into two main types: qualitative and sequential. Qualitative palettes are designed for categorical data, where the focus is on distinct colors rather than the transition between them. Sequential palettes, on the other hand, are ideal for continuous data, as they emphasize the transition between colors to represent varying magnitudes.

Pink and sage aesthetic color palette with soft neutral tones, including cream, blush, rosewood, green and blue shades.
Pink and sage aesthetic color palette with soft neutral tones, including cream, blush, rosewood, green and blue shades.

Built-in Matplotlib Color Palettes

Matplotlib offers a diverse set of built-in color palettes, each serving a unique purpose. These palettes are named and can be accessed using the plt.cm (color map) object. Some of the most commonly used palettes include 'viridis', 'plasma', 'inferno', 'magma', and 'nipy_spectral'.

Colour Palette #02
Colour Palette #02

To use these palettes, you can simply pass the name of the desired palette as an argument to the colormap parameter of your plot function. For example, to create a plot using the 'viridis' palette, you would use plt.imshow(data, cmap='viridis').

Qualitative Palettes

Color Combinaisons: Palette for Graphic Design #130
Color Combinaisons: Palette for Graphic Design #130

Qualitative palettes are designed for categorical data, where the focus is on distinct colors rather than the transition between them. Some popular qualitative palettes in Matplotlib include 'Set1', 'Set2', 'Set3', and 'Dark2'. These palettes provide a set of distinct, easily distinguishable colors, perfect for bar charts, pie charts, and other categorical plots.

To use a qualitative palette, you can pass its name as a string to the c parameter of your plot function. For instance, to create a bar plot using the 'Set1' palette, you would use plt.bar(x, y, color='Set1').

Sequential Palettes

paleta de colores dti
paleta de colores dti

Sequential palettes are ideal for continuous data, as they emphasize the transition between colors to represent varying magnitudes. Some popular sequential palettes in Matplotlib include 'viridis', 'plasma', 'inferno', and 'magma'. These palettes provide a smooth transition between colors, making them perfect for heatmaps, contour plots, and other continuous data visualizations.

To use a sequential palette, you can pass its name as a string to the cmap parameter of your plot function. For example, to create a heatmap using the 'viridis' palette, you would use plt.imshow(data, cmap='viridis').

Creating Custom Color Palettes

Color Palette 008
Color Palette 008

While Matplotlib's built-in palettes offer a wide range of options, you may sometimes need to create your own custom palette to better suit your visualization needs. Matplotlib allows you to create custom palettes using various methods, such as using a list of colors, a color map, or even an image.

One simple way to create a custom palette is by passing a list of colors to the cmap parameter. For instance, to create a custom palette with three colors, you can use plt.imshow(data, cmap=['red', 'green', 'blue']).

an image of the back side of a poster with different colors and shapes on it
an image of the back side of a poster with different colors and shapes on it
Designer Neutral Color Palette | Modern Minimal Colors
Designer Neutral Color Palette | Modern Minimal Colors
the color palette is shown with different colors and font on each side, including pink, purple
the color palette is shown with different colors and font on each side, including pink, purple
Custom Calligraphy Font
Custom Calligraphy Font
5 Colour Pallet Covers "Mosslands" Aesthetic Themed 💚
5 Colour Pallet Covers "Mosslands" Aesthetic Themed 💚
'Grab Coffee With Me' Color Palette
'Grab Coffee With Me' Color Palette
the different font styles and colors are shown in this graphic style, which is also used for
the different font styles and colors are shown in this graphic style, which is also used for
5 Colour Pallet Covers "Matcha Mecha" Aesthetic Themed 💚
5 Colour Pallet Covers "Matcha Mecha" Aesthetic Themed 💚
Color Palette 040
Color Palette 040
the color scheme for different font and numbers
the color scheme for different font and numbers
an image of the back side of a poster with different font and numbers on it
an image of the back side of a poster with different font and numbers on it
List of named colors
List of named colors
an image of flowers with the names of them in different colors and font options on it
an image of flowers with the names of them in different colors and font options on it
дичь какая
дичь какая
5 Color Pallet Covers "Splendour and Pride" Aesthetic Themed 💙
5 Color Pallet Covers "Splendour and Pride" Aesthetic Themed 💙
an iphone screen showing the font and numbers in different colors
an iphone screen showing the font and numbers in different colors
a set of four different colored labels with the same font and numbers on them, all in
a set of four different colored labels with the same font and numbers on them, all in
Color Palette 095
Color Palette 095
5 Colour Pallet Covers "Hula Girl" Aesthetic Themed ❤️
5 Colour Pallet Covers "Hula Girl" Aesthetic Themed ❤️

Using Color Maps

Color maps in Matplotlib are a powerful tool for creating custom palettes. A color map is essentially a function that maps data values to colors. Matplotlib provides several built-in color maps, and you can also create your own using various methods, such as linear interpolation or using a colormap from another library.

To use a color map, you can pass its name as a string to the cmap parameter of your plot function. For example, to create a plot using the 'jet' color map, you would use plt.imshow(data, cmap='jet').

Using Images as Color Palettes

Another unique way to create a custom palette in Matplotlib is by using an image. You can use any image as a color palette by passing it to the cmap parameter as an instance of the matplotlib.image class. This allows you to create truly unique and visually appealing color palettes.

To use an image as a color palette, you first need to load the image using matplotlib.image.imread and then pass it to the cmap parameter. For example, plt.imshow(data, cmap=matplotlib.image.imread('image.jpg')).

In conclusion, Matplotlib's color palettes offer a wealth of possibilities for enhancing the aesthetics and readability of your visualizations. Whether you're using built-in palettes or creating your own, understanding and effectively utilizing color palettes can greatly improve the impact of your data visualizations. So go ahead, experiment with different palettes, and let your data shine!