# Bokeh Palettes for Color Mapping and Plotting in Python

Greetings! Some links on this site are affiliate links. That means that, if you choose to make a purchase, The Click Reader may earn a small commission at no extra cost to you. We greatly appreciate your support!

Similar to how a painter uses a color palette to make a painting, a Bokeh palette is a collection of colors for color mapping in Python. Bokeh provides 5 different Bokeh Palettes for plotting in Python where each color palette has its own set of colors:

1. Matplotlib Bokeh Palette
2. D3 Bokeh Palette
3. Brewer Bokeh Palette
4. Color-Deficient Usability Bokeh Palette
5. Large Bokeh Palette

Let us go over some of these color palettes one-by-one in this article and learn how to use the palettes.

## 1. Matplotlib Bokeh Palette

Bokeh includes the Matplotlib palettes called Magma, Inferno, Plasma, Viridis, and Cividis. Here is a visual aid to understand which palette provides which color map:

Using the Matplotlib Bokeh Palette is extremely simple and you only have to specify the `color` parameter in your plots as shown below:

```# Importing Bokeh plotting and palettes modules
from bokeh.plotting import figure, output_file, show
from bokeh.palettes import Magma, Inferno, Plasma, Viridis, Cividis

# File to save the model
output_file("output.html")

# Instantiating the figure object
graph = figure(title = "Bokeh Palettes")

# Demonstrating the Magma palette
graph.vbar(x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
top = [9] * 11,
bottom = [8] * 11,
width = 1,
color = Magma[11])

# Demonstrating the Inferno palette
graph.vbar(x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
top = [7] * 11,
bottom = [6] * 11,
width = 1,
color = Inferno[11])

# Demonstrating the Plasma palette
graph.vbar(x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
top = [5] * 11,
bottom = [4] * 11,
width = 1,
color = Plasma[11])

# Demonstrating the Viridis palette
graph.vbar(x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
top = [3] * 11,
bottom = [2] * 11,
width = 1,
color = Viridis[11])

# Demonstrating the Cividis palette
graph.vbar(x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
top = [1] * 11,
width = 1,
color = Cividis[11])

# Showing the model
show(graph)```

## D3 Bokeh Palette

Bokeh includes the categorical palettes from D3, which are shown below:

Using the D3 Bokeh Palette is extremely simple and you only have to specify the `color` parameter in your plots as shown below:

```# Importing Bokeh plotting and palettes modules
from bokeh.plotting import figure, output_file, show
from bokeh.palettes import Category10, Category20, Category20b, Category20c

# File to save the model
output_file("output.html")

# Instantiating the figure object
graph = figure(title = "Bokeh Palettes")

# Demonstrating the Category10 palette
graph.vbar(x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
top = [9] * 10,
bottom = [8] * 10,
width = 1,
color = Category10[10])

# Demonstrating the Category20 palette
graph.vbar(x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
top = [7] * 10,
bottom = [6] * 10,
width = 1,
color = Category20[10])

# Demonstrating the Category20b palette
graph.vbar(x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
top = [5] * 10,
bottom = [4] * 10,
width = 1,
color = Category20b[10])

# Demonstrating the Category20c palette
graph.vbar(x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
top = [3] * 10,
bottom = [2] * 10,
width = 1,
color = Category20c[10])

# Showing the model
show(graph)```

To learn about the rest of the color palette, you can refer to the official Bokeh.Palette documentation. The implementation method is same as displayed for the two palettes above.

Do you want to learn Python, Data Science, and Machine Learning while getting certified? Here are some best selling Datacamp courses that we recommend you enroll in:

1. Introduction to Python (Free Course) - 1,000,000+ students already enrolled!
2. Introduction to Data Science  in Python- 400,000+ students already enrolled!
3. Introduction to TensorFlow for Deep Learning with Python - 90,000+ students already enrolled!
4. Data Science and Machine Learning Bootcamp with R - 70,000+ students already enrolled!