bokeh.core.property_mixins

Mix-in classes that bulk add groups of properties to Bokeh models.

Some groups of properties often show up in Bokeh models together. For instance, any model that exposes a fill color property for use when rendering will almost always want to expose a fill alpha as well. To reduce boilerplate code and simplify defining models with these sets of properties, use the mix-in classes in this module:

  • FillProps — properties for fill color and alpha

  • HatchProps — properties for hatching pattern, color, alpha, etc.

  • LineProps — properties for line color, dashing, width, etc.

  • TextProps — properties for text color, font, etc.

To include these properties in a Bokeh model, use the Include property as shown here:

class SomeGlyph(Glyph):

    fill_props = Include(FillProps, help="""
    The {prop} values for the annular wedges.
    """)

This adds all the fill properties fill_color and fill_alpha to this model. The help string contains a placeholder {prop}. When docs for this class are rendered by the, the placeholder will be replaced with more information specific to each property.

class FillProps(**properties: Any)[source]

Properties relevant to rendering fill regions.

Mirrors the BokehJS properties.FillVector class.

fill_alpha = 1.0
Type

AlphaSpec

An alpha value to use to fill paths with.

Acceptable values are numbers in 0..1 range (transparent..opaque).

fill_color = 'gray'
Type

ColorSpec

A color to use to fill paths with.

Acceptable values are:

  • any of the named CSS colors, e.g 'green', 'indigo'

  • RGB(A) hex strings, e.g., '#FF0000', '#44444444'

  • CSS4 color strings, e.g., 'rgba(255, 0, 127, 0.6)', 'rgb(0 127 0 / 1.0)'

  • a 3-tuple of integers (r, g, b) between 0 and 255

  • a 4-tuple of (r, g, b, a) where r, g, b are integers between 0..255 and a is between 0..1

  • a 32-bit unsiged integers using the 0xRRGGBBAA byte order pattern

class HatchProps(**properties: Any)[source]

Properties relevant to rendering fill regions.

Mirrors the BokehJS properties.HatchVector class.

hatch_alpha = 1.0
Type

AlphaSpec

An alpha value to use to hatching with.

Acceptable values are numbers in 0..1 range (transparent..opaque).

hatch_color = 'black'
Type

ColorSpec

A color to use to hatching with.

Acceptable values are:

  • any of the named CSS colors, e.g 'green', 'indigo'

  • RGB(A) hex strings, e.g., '#FF0000', '#44444444'

  • CSS4 color strings, e.g., 'rgba(255, 0, 127, 0.6)', 'rgb(0 127 0 / 1.0)'

  • a 3-tuple of integers (r, g, b) between 0 and 255

  • a 4-tuple of (r, g, b, a) where r, g, b are integers between 0..255 and a is between 0..1

  • a 32-bit unsiged integers using the 0xRRGGBBAA byte order pattern

hatch_pattern = None
Type

HatchPatternSpec

Built-in patterns are can either be specified as long names:

blank, dot, ring, horizontal_line, vertical_line, cross, horizontal_dash, vertical_dash, spiral, right_diagonal_line, left_diagonal_line, diagonal_cross, right_diagonal_dash, left_diagonal_dash, horizontal_wave, vertical_wave, criss_cross

or as one-letter abbreviations:

‘ ‘, ‘.’, ‘o’, ‘-’, ‘|’, ‘+’, ‘”’, ‘:’, ‘@’, ‘/’, ‘\’, ‘x’, ‘,’, ‘`’, ‘v’, ‘>’, ‘*’

hatch_scale = 12.0
Type

NumberSpec

A rough measure of the ‘size’ of the hatching pattern. Generally speaking, the higher the number, the more spread out the pattern will be.

hatch_weight = 1.0
Type

NumberSpec

A width value for line-strokes used in hatching.

class LineProps(**properties: Any)[source]

Properties relevant to rendering path operations.

Mirrors the BokehJS properties.LineVector class.

line_alpha = 1.0
Type

AlphaSpec

An alpha value to use to stroke paths with.

Acceptable values are numbers in 0..1 range (transparent..opaque).

line_cap = 'butt'
Type

LineCapSpec

How path segments should be terminated.

Acceptable values are:

  • 'butt' butt_cap

  • 'round' round_cap

  • 'square' square_cap

line_color = 'black'
Type

ColorSpec

A color to use to stroke paths with.

Acceptable values are:

  • any of the named CSS colors, e.g 'green', 'indigo'

  • RGB(A) hex strings, e.g., '#FF0000', '#44444444'

  • CSS4 color strings, e.g., 'rgba(255, 0, 127, 0.6)', 'rgb(0 127 0 / 1.0)'

  • a 3-tuple of integers (r, g, b) between 0 and 255

  • a 4-tuple of (r, g, b, a) where r, g, b are integers between 0..255 and a is between 0..1

  • a 32-bit unsiged integers using the 0xRRGGBBAA byte order pattern

line_dash = []
Type

DashPatternSpec

How should the line be dashed.

line_dash_offset = 0
Type

IntSpec

The distance into the line_dash (in pixels) that the pattern should start from.

line_join = 'bevel'
Type

LineJoinSpec

How path segments should be joined together.

Acceptable values are:

  • 'miter' miter_join

  • 'round' round_join

  • 'bevel' bevel_join

line_width = 1
Type

NumberSpec

Stroke width in units of pixels.

class ScalarFillProps(**properties: Any)[source]

Properties relevant to rendering fill regions.

Mirrors the BokehJS properties.Fill class.

fill_alpha = 1.0
Type

Alpha

An alpha value to use to %s with.

Acceptable values are floating-point numbers between 0 and 1 (0 being transparent and 1 being opaque).

fill_color = 'gray'
Type

Nullable(Color)

A color to use to fill paths with.

class ScalarHatchProps(**properties: Any)[source]

Properties relevant to rendering fill regions.

Mirrors the BokehJS properties.Hatch class.

hatch_alpha = 1.0
Type

Alpha

An alpha value to use to hatching with.

Acceptable values are floating-point numbers between 0 and 1 (0 being transparent and 1 being opaque).

hatch_color = 'black'
Type

Nullable(Color)

A color to use to hatching with.

hatch_pattern = None
Type

Nullable(String)

Built-in patterns are can either be specified as long names:

blank, dot, ring, horizontal_line, vertical_line, cross, horizontal_dash, vertical_dash, spiral, right_diagonal_line, left_diagonal_line, diagonal_cross, right_diagonal_dash, left_diagonal_dash, horizontal_wave, vertical_wave, criss_cross

or as one-letter abbreviations:

‘ ‘, ‘.’, ‘o’, ‘-’, ‘|’, ‘+’, ‘”’, ‘:’, ‘@’, ‘/’, ‘\’, ‘x’, ‘,’, ‘`’, ‘v’, ‘>’, ‘*’

hatch_scale = 12.0
Type

Size

A rough measure of the ‘size’ of the hatching pattern. Generally speaking, the higher the number, the more spread out the pattern will be.

hatch_weight = 1.0
Type

Size

A width value for line-strokes used in hatching.

class ScalarLineProps(**properties: Any)[source]

Properties relevant to rendering path operations.

Mirrors the BokehJS properties.Line class.

line_alpha = 1.0
Type

Alpha

An alpha value to use to stroke paths with.

Acceptable values are floating-point numbers between 0 and 1 (0 being transparent and 1 being opaque).

line_cap = 'butt'
Type

Enum(LineCap)

How path segments should be terminated.

Acceptable values are:

  • 'butt' butt_cap

  • 'round' round_cap

  • 'square' square_cap

line_color = 'black'
Type

Nullable(Color)

A color to use to stroke paths with.

line_dash = []
Type

DashPattern

How should the line be dashed.

line_dash_offset = 0
Type

Int

The distance into the line_dash (in pixels) that the pattern should start from.

line_join = 'bevel'
Type

Enum(LineJoin)

How path segments should be joined together.

Acceptable values are:

  • 'miter' miter_join

  • 'round' round_join

  • 'bevel' bevel_join

line_width = 1
Type

Float

Stroke width in units of pixels.

class ScalarTextProps(**properties: Any)[source]

Properties relevant to rendering text.

Mirrors the BokehJS properties.Text class.

Note

There is currently only support for filling text. An interface to stroke the outlines of text has not yet been exposed.

text_align = 'left'
Type

Enum(TextAlign)

Horizontal anchor point to use when rendering text.

Acceptable values are:

  • 'left'

  • 'right'

  • 'center'

text_alpha = 1.0
Type

Alpha

An alpha value to use to fill text with.

Acceptable values are floating-point numbers between 0 and 1 (0 being transparent and 1 being opaque).

text_baseline = 'bottom'
Type

Enum(TextBaseline)

Vertical anchor point to use when rendering text.

Acceptable values are:

  • 'top'

  • 'middle'

  • 'bottom'

  • 'alphabetic'

  • 'hanging'

  • 'ideographic'

text_color = '#444444'
Type

Nullable(Color)

A color to use to fill text with.

text_font = 'helvetica'
Type

String

Name of a font to use for rendering text, e.g., 'times', 'helvetica'.

text_font_style = 'normal'
Type

Enum(FontStyle)

A style to use for rendering text.

Acceptable values are:

  • 'normal' normal text

  • 'italic' italic text

  • 'bold' bold text

  • "bold italic" *bold italic text*

text_line_height = 1.2
Type

Float

In multi-line text, how much additional space should be allocated for each line. The value is provided as a number, but should be treated as a percentage of font size. The default is 120%. Setting it to 1.0, so 100%, means no additional space will be used.

class TextProps(**properties: Any)[source]

Properties relevant to rendering text.

Mirrors the BokehJS properties.TextVector class.

Note

There is currently only support for filling text. An interface to stroke the outlines of text has not yet been exposed.

text_align = 'left'
Type

TextAlignSpec

Horizontal anchor point to use when rendering text.

Acceptable values are:

  • 'left'

  • 'right'

  • 'center'

text_alpha = 1.0
Type

AlphaSpec

An alpha value to use to fill text with.

Acceptable values are numbers in 0..1 range (transparent..opaque).

text_baseline = 'bottom'
Type

TextBaselineSpec

Vertical anchor point to use when rendering text.

Acceptable values are:

  • 'top'

  • 'middle'

  • 'bottom'

  • 'alphabetic'

  • 'hanging'

  • 'ideographic'

text_color = '#444444'
Type

ColorSpec

A color to use to fill text with.

Acceptable values are:

  • any of the named CSS colors, e.g 'green', 'indigo'

  • RGB(A) hex strings, e.g., '#FF0000', '#44444444'

  • CSS4 color strings, e.g., 'rgba(255, 0, 127, 0.6)', 'rgb(0 127 0 / 1.0)'

  • a 3-tuple of integers (r, g, b) between 0 and 255

  • a 4-tuple of (r, g, b, a) where r, g, b are integers between 0..255 and a is between 0..1

  • a 32-bit unsiged integers using the 0xRRGGBBAA byte order pattern

text_font = {'value': 'helvetica'}
Type

StringSpec

Name of a font to use for rendering text, e.g., 'times', 'helvetica'.

text_font_style = 'normal'
Type

FontStyleSpec

A style to use for rendering text.

Acceptable values are:

  • 'normal' normal text

  • 'italic' italic text

  • 'bold' bold text

  • "bold italic" *bold italic text*

text_line_height = 1.2
Type

NumberSpec

In multi-line text, how much additional space should be allocated for each line. The value is provided as a number, but should be treated as a percentage of font size. The default is 120%. Setting it to 1.0, so 100%, means no additional space will be used.