VOOZH about

URL: https://www.geeksforgeeks.org/python/how-to-use-color-palettes-in-python-bokeh/

⇱ How to use Color Palettes in Python-Bokeh? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to use Color Palettes in Python-Bokeh?

Last Updated : 15 Jul, 2025
Bokeh is a Python interactive data visualization. It renders its plots using HTML and JavaScript. It targets modern web browsers for presentation providing elegant, concise construction of novel graphics with high-performance interactivity. Bokeh provides us with multiple color palettes in the bokeh.palettes module. Let us see how to use these color palettes in Bokeh. A palette is a simple plain Python list of (hex) RGB color strings. For example, the blues8 palette has the colors : ('#084594', '#2171b5', '#4292c6', '#6baed6', '#9ecae1', '#c6dbef', '#deebf7', '#f7fbff'). There are 5 types of built-in color palettes in Bokeh :
  1. Matplotlib Palettes
  2. D3 Palettes
  3. Brewer Palettes
  4. Color-Deficient Usability Palette
  5. Large Palettes

Matplotlib Palettes

Bokeh provides us with Matplotlib color palettes. There are 5 types of Matplotlib color palettes :
  • Magma
  • Inferno
  • Plasma
  • Viridis
  • Cividis
Each type of color palette has 10 different versions of the palette with varying number of colors, which are 3, 4, 5, 6, 7, 8, 9, 10, 11 and 256. Example : We will be demonstrating the Matplotlib palettes by plotting multiple vertical bars using the vbar() function. Output : 👁 Image

D3 Palettes

Bokeh provides us with D3 categorical color palettes. There are 4 types of D3 color palettes available :
  • Category10
  • Category20
  • Category20b
  • Category20c
Example : We will be demonstrating the D3 palettes by plotting multiple vertical bars using the vbar() function. Output : 👁 Image

Brewer Palettes

Bokeh provides us with ColorBrewer palettes. There are 35 types of ColorBrewer palettes available :
  • Accent
  • Blues
  • BrBG
  • BuGn
  • BuPu
  • Dark2
  • GnBu
  • Greens
  • Greys
  • OrRd
  • Oranges
  • PRGn
  • Paired
  • Pastel1
  • Pastel2
  • PiYG
  • PuBu
  • PuBuGn
  • PuOr
  • PuRd
  • Purples
  • RdBu
  • RdGy
  • RdPu
  • RdYlBu
  • RdYlGn
  • Reds
  • Set1
  • Set2
  • Set3
  • Spectral
  • YlGn
  • YlGnBu
  • YlOrBr
  • YlOrRd
Example : We will be demonstrating the ColorBrewer palettes by plotting multiple vertical bars using the vbar() function. Output : 👁 Image

Usability Palettes

Bokeh provides us with a palette that is useful for people with color deficiency or color blindness. Example : We will be demonstrating the usability palette by plotting multiple vertical bars using the vbar() function. Output : 👁 Image

Large Palettes

The color palettes discussed above might be small for some applications. Bokeh provides us with large palettes that have 256 colors each. There are 7 large palettes :
  • Greys256
  • Inferno256
  • Magma256
  • Plasma256
  • Viridis256
  • Cividis256
  • Turbo256
Example : We will be demonstrating the large palettes by plotting multiple vertical bars using the vbar() function.
Output : 👁 Image
Comment
Article Tags:
Article Tags: