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, use_prefix=False, help="""
    The %s values for the annular wedges.
    """)

This adds all the fill properties fill_color and fill_alpha to this model with one simple statement. Note that the help string contains a placeholder format %s. When docs for this class are rendered by the bokeh_model Sphinx extension, the placeholder will be replaced with more information specific to each property. The setting use_prefix means that the names of the properties added to SomeGlyph are exactly fill_alpha and fill_color. Some situations require a different usage, for more information see the docs for Include.

class FillProps(**properties)[source]

Properties relevant to rendering fill regions.

Mirrors the BokehJS properties.FillVector class.

fill_alpha
Property type

AlphaSpec

Default value

1.0

An alpha value to use to fill paths with.

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

fill_color
Property type

ColorSpec

Default value

'gray'

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)[source]

Properties relevant to rendering fill regions.

Mirrors the BokehJS properties.HatchVector class.

hatch_alpha
Property type

AlphaSpec

Default value

1.0

An alpha value to use to hatching with.

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

hatch_color
Property type

ColorSpec

Default value

'black'

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
Property type

HatchPatternSpec

Default value

None

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
Property type

NumberSpec

Default value

12.0

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
Property type

NumberSpec

Default value

1.0

A width value for line-strokes used in hatching.

class LineProps(**properties)[source]

Properties relevant to rendering path operations.

Mirrors the BokehJS properties.LineVector class.

line_alpha
Property type

AlphaSpec

Default value

1.0

An alpha value to use to stroke paths with.

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

line_cap
Property type

LineCapSpec

Default value

'butt'

How path segments should be terminated.

Acceptable values are:

  • 'butt' butt_cap

  • 'round' round_cap

  • 'square' square_cap

line_color
Property type

ColorSpec

Default value

'black'

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
Property type

DashPatternSpec

Default value

[]

How should the line be dashed.

line_dash_offset
Property type

IntSpec

Default value

0

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

line_join
Property type

LineJoinSpec

Default value

'bevel'

How path segments should be joined together.

Acceptable values are:

  • 'miter' miter_join

  • 'round' round_join

  • 'bevel' bevel_join

line_width
Property type

NumberSpec

Default value

1

Stroke width in units of pixels.

class ScalarFillProps(**properties)[source]

Properties relevant to rendering fill regions.

Mirrors the BokehJS properties.Fill class.

fill_alpha
Property type

Alpha

Default value

1.0

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
Property type

Nullable(Color)

Default value

'gray'

A color to use to fill paths with.

class ScalarHatchProps(**properties)[source]

Properties relevant to rendering fill regions.

Mirrors the BokehJS properties.Hatch class.

hatch_alpha
Property type

Alpha

Default value

1.0

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
Property type

Nullable(Color)

Default value

'black'

A color to use to hatching with.

hatch_pattern
Property type

Nullable(String)

Default value

None

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
Property type

Size

Default value

12.0

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
Property type

Size

Default value

1.0

A width value for line-strokes used in hatching.

class ScalarLineProps(**properties)[source]

Properties relevant to rendering path operations.

Mirrors the BokehJS properties.Line class.

line_alpha
Property type

Alpha

Default value

1.0

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
Property type

Enum(LineCap)

Default value

'butt'

How path segments should be terminated.

Acceptable values are:

  • 'butt' butt_cap

  • 'round' round_cap

  • 'square' square_cap

line_color
Property type

Nullable(Color)

Default value

'black'

A color to use to stroke paths with.

line_dash
Property type

DashPattern

Default value

[]

How should the line be dashed.

line_dash_offset
Property type

Int

Default value

0

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

line_join
Property type

Enum(LineJoin)

Default value

'bevel'

How path segments should be joined together.

Acceptable values are:

  • 'miter' miter_join

  • 'round' round_join

  • 'bevel' bevel_join

line_width
Property type

Float

Default value

1

Stroke width in units of pixels.

class ScalarTextProps(**properties)[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
Property type

Enum(TextAlign)

Default value

'left'

Horizontal anchor point to use when rendering text.

Acceptable values are:

  • 'left'

  • 'right'

  • 'center'

text_alpha
Property type

Alpha

Default value

1.0

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
Property type

Enum(TextBaseline)

Default value

'bottom'

Vertical anchor point to use when rendering text.

Acceptable values are:

  • 'top'

  • 'middle'

  • 'bottom'

  • 'alphabetic'

  • 'hanging'

  • 'ideographic'

text_color
Property type

Nullable(Color)

Default value

'#444444'

A color to use to fill text with.

text_font
Property type

String

Default value

'helvetica'

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

text_font_style
Property type

Enum(FontStyle)

Default value

'normal'

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
Property type

Float

Default value

1.2

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)[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
Property type

TextAlignSpec

Default value

'left'

Horizontal anchor point to use when rendering text.

Acceptable values are:

  • 'left'

  • 'right'

  • 'center'

text_alpha
Property type

AlphaSpec

Default value

1.0

An alpha value to use to fill text with.

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

text_baseline
Property type

TextBaselineSpec

Default value

'bottom'

Vertical anchor point to use when rendering text.

Acceptable values are:

  • 'top'

  • 'middle'

  • 'bottom'

  • 'alphabetic'

  • 'hanging'

  • 'ideographic'

text_color
Property type

ColorSpec

Default value

'#444444'

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
Property type

StringSpec

Default value

{'value': 'helvetica'}

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

text_font_style
Property type

FontStyleSpec

Default value

'normal'

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
Property type

NumberSpec

Default value

1.2

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.