bokeh.colors

Provide classes for representing RGB(A) and HSL(A) colors, as well as define common named colors.

bokeh.colors.Color

Provide a base class for representing color values.

class Color[source]

A base class for representing color objects.

static clamp(value, maximum=None)[source]

Clamp numeric values to be non-negative, an optionally, less than a given maximum.

Parameters:
  • value (float) – A number to clamp.
  • maxiumum (float, optional) – A max bound to to clamp to. If None, there is no upper bound, and values are only clamped to be non-negative. (default: None)
Returns:

float

copy()[source]

Copy this color.

Subclasses must implement this method.

darken(amount)[source]

Darken (reduce the luminance) of this color.

Parameters:amount (float) – Amount to reduce the luminance by (clamped above zero)
Returns:Color
classmethod from_hsl(value)[source]

Create a new color by converting from an HSL color.

Subclasses must implement this method.

Parameters:value (HSL) – A color to convert from HSL
Returns:Color
classmethod from_rgb(value)[source]

Create a new color by converting from an RGB color.

Subclasses must implement this method.

Parameters:value (RGB) – A color to convert from RGB
Returns:Color
lighten(amount)[source]

Lighten (increase the luminance) of this color.

Parameters:amount (float) – Amount to increase the luminance by (clamped above zero)
Returns:Color
to_css()[source]

Return a CSS representation of this color.

Subclasses must implement this method.

Returns:str
to_hsl()[source]

Create a new HSL color by converting from this color.

Subclasses must implement this method.

Returns:HSL
to_rgb()[source]

Create a new HSL color by converting from this color.

Subclasses must implement this method.

Returns:RGB

bokeh.colors.HSL

Provide a class to represent colors with HSL (Hue, Saturation, Value).

class HSL(h, s, l, a=1.0)[source]

Represent colors by specifying their Hue, Saturation, and Value.

Alpha values may also optionally be provided. Otherwise, alpha values default to 1.

__init__(h, s, l, a=1.0)[source]
Parameters:
  • h (int) – The Hue, in [0, 255]
  • h – The Saturation, in [0, 1]
  • h – The Value, in [0, 1]
  • a (float, optional) – An alpha value for this color in [0, 1] (default: 1.0)
clamp(value, maximum=None)

Clamp numeric values to be non-negative, an optionally, less than a given maximum.

Parameters:
  • value (float) – A number to clamp.
  • maxiumum (float, optional) – A max bound to to clamp to. If None, there is no upper bound, and values are only clamped to be non-negative. (default: None)
Returns:

float

copy()[source]

Return a copy of this color value.

Returns:HSL
darken(amount)

Darken (reduce the luminance) of this color.

Parameters:amount (float) – Amount to reduce the luminance by (clamped above zero)
Returns:Color
classmethod from_hsl(value)[source]

Copy an HSL color from another HSL color value.

Parameters:value (HSL) – The HSL color to copy.
Returns:HSL
classmethod from_rgb(value)[source]

Create an HSL color from an RGB color value.

Parameters:value (RGB) – The RGB color to convert.
Returns:HSL
lighten(amount)

Lighten (increase the luminance) of this color.

Parameters:amount (float) – Amount to increase the luminance by (clamped above zero)
Returns:Color
to_css()[source]

Generate the CSS representation of this HSL color.

Returns:str, "hsl(...)" or "hsla(...)"
to_hsl()[source]

Return a HSL copy for this HSL color.

Returns:HSL
to_rgb()[source]

Return a corresponding RGB color for this HSL color.

Returns:HSL

bokeh.colors.RGB

class RGB(r, g, b, a=1.0)[source]

Represent colors by specifying their Red, Green, and Blue channels.

Alpha values may also optionally be provided. Otherwise, alpha values default to 1.

__init__(r, g, b, a=1.0)[source]
Parameters:
  • r (int) – The value for the red channel in [0, 255]
  • g (int) – The value for the green channel in [0, 255]
  • b (int) – The value for the blue channel in [0, 255]
  • a (float, optional) – An alpha value for this color in [0, 1] (default: 1.0)
clamp(value, maximum=None)

Clamp numeric values to be non-negative, an optionally, less than a given maximum.

Parameters:
  • value (float) – A number to clamp.
  • maxiumum (float, optional) – A max bound to to clamp to. If None, there is no upper bound, and values are only clamped to be non-negative. (default: None)
Returns:

float

copy()[source]

Return a copy of this color value.

Returns:RGB
darken(amount)

Darken (reduce the luminance) of this color.

Parameters:amount (float) – Amount to reduce the luminance by (clamped above zero)
Returns:Color
classmethod from_hsl(value)[source]

Create an RGB color from an HSL color value.

Parameters:value (HSL) – The HSL color to convert.
Returns:RGB
classmethod from_rgb(value)[source]

Copy an RGB color from another RGB color value.

Parameters:value (RGB) – The RGB color to copy.
Returns:RGB
lighten(amount)

Lighten (increase the luminance) of this color.

Parameters:amount (float) – Amount to increase the luminance by (clamped above zero)
Returns:Color
to_css()[source]

Generate the CSS representation of this RGB color.

Returns:str, "rgb(...)" or "rgba(...)"
to_hex()[source]

Return a hex color string for this RGB color.

Any alpha value on this color is discarded, only hex color strings for the RGB components are returned.

Returns:str, "#RRGGBB"
to_hsl()[source]

Return a corresponding HSL color for this RGB color.

Returns:RGB
to_rgb()[source]

Return a RGB copy for this RGB color.

Returns:RGB

bokeh.colors.groups

Organize CSS named colors into useful groups according to general hue.

class pink[source]

CSS “Pink” Color Group as defined by https://www.w3schools.com/colors/colors_groups.asp

pink
lightpink
hotpink
deeppink
palevioletred
mediumvioletred
class red[source]

CSS “Red” Color Group as defined by https://www.w3schools.com/colors/colors_groups.asp

lightsalmon
salmon
darksalmon
lightcoral
indianred
crimson
firebrick
darkred
red
class orange[source]

CSS “Orange” Color Group as defined by https://www.w3schools.com/colors/colors_groups.asp

orangered
tomato
coral
darkorange
orange
class yellow[source]

CSS “Yellow” Color Group as defined by https://www.w3schools.com/colors/colors_groups.asp

yellow
lightyellow
lemonchiffon
lightgoldenrodyellow
papayawhip
moccasin
peachpuff
palegoldenrod
khaki
darkkhaki
gold
class brown[source]

CSS “Brown” Color Group as defined by https://www.w3schools.com/colors/colors_groups.asp

{colors}

class green[source]

CSS “Green” Color Group as defined by https://www.w3schools.com/colors/colors_groups.asp

darkolivegreen
olive
olivedrab
yellowgreen
limegreen
lime
lawngreen
chartreuse
greenyellow
springgreen
mediumspringgreen
lightgreen
palegreen
darkseagreen
mediumseagreen
seagreen
forestgreen
green
darkgreen
class cyan[source]

CSS “Cyan” Color Group as defined by https://www.w3schools.com/colors/colors_groups.asp

mediumaquamarine
aqua
cyan
lightcyan
paleturquoise
aquamarine
turquoise
mediumturquoise
darkturquoise
lightseagreen
cadetblue
darkcyan
teal
class blue[source]

CSS “Blue” Color Group as defined by https://www.w3schools.com/colors/colors_groups.asp

lightsteelblue
powderblue
lightblue
skyblue
lightskyblue
deepskyblue
dodgerblue
cornflowerblue
steelblue
royalblue
blue
mediumblue
darkblue
navy
midnightblue
class purple[source]

CSS “Purple” Color Group as defined by https://www.w3schools.com/colors/colors_groups.asp

lavender
thistle
plum
violet
orchid
fuchsia
magenta
mediumorchid
mediumpurple
blueviolet
darkviolet
darkorchid
darkmagenta
purple
indigo
darkslateblue
slateblue
mediumslateblue
class white[source]

CSS “White” Color Group as defined by https://www.w3schools.com/colors/colors_groups.asp

white
snow
honeydew
mintcream
azure
aliceblue
ghostwhite
whitesmoke
seashell
beige
oldlace
floralwhite
ivory
antiquewhite
linen
lavenderblush
mistyrose
class black[source]

CSS “Black” Color Group as defined by https://www.w3schools.com/colors/colors_groups.asp

gainsboro
lightgray
silver
darkgray
gray
dimgray
lightslategray
slategray
darkslategray
black

bokeh.colors.named

Provide the standard 147 CSS (X11) named colors.

aliceblue
antiquewhite
aqua
aquamarine
azure
beige
bisque
black
blanchedalmond
blue
blueviolet
brown
burlywood
cadetblue
chartreuse
chocolate
coral
cornflowerblue
cornsilk
crimson
cyan
darkblue
darkcyan
darkgoldenrod
darkgray
darkgreen
darkgrey
darkkhaki
darkmagenta
darkolivegreen
darkorange
darkorchid
darkred
darksalmon
darkseagreen
darkslateblue
darkslategray
darkslategrey
darkturquoise
darkviolet
deeppink
deepskyblue
dimgray
dimgrey
dodgerblue
firebrick
floralwhite
forestgreen
fuchsia
gainsboro
ghostwhite
gold
goldenrod
gray
green
greenyellow
grey
honeydew
hotpink
indianred
indigo
ivory
khaki
lavender
lavenderblush
lawngreen
lemonchiffon
lightblue
lightcoral
lightcyan
lightgoldenrodyellow
lightgray
lightgreen
lightgrey
lightpink
lightsalmon
lightseagreen
lightskyblue
lightslategray
lightslategrey
lightsteelblue
lightyellow
lime
limegreen
linen
magenta
maroon
mediumaquamarine
mediumblue
mediumorchid
mediumpurple
mediumseagreen
mediumslateblue
mediumspringgreen
mediumturquoise
mediumvioletred
midnightblue
mintcream
mistyrose
moccasin
navajowhite
navy
oldlace
olive
olivedrab
orange
orangered
orchid
palegoldenrod
palegreen
paleturquoise
palevioletred
papayawhip
peachpuff
peru
pink
plum
powderblue
purple
red
rosybrown
royalblue
saddlebrown
salmon
sandybrown
seagreen
seashell
sienna
silver
skyblue
slateblue
slategray
slategrey
snow
springgreen
steelblue
tan
teal
thistle
tomato
turquoise
violet
wheat
white
whitesmoke
yellow
yellowgreen