markers

Display a variety of simple scatter marker shapes whose attributes can be associated with data columns from ColumnDataSource objects.

Warning

The individual marker classes in this module are deprecated since Bokeh 2.3.0. Please replace all occurrences of Marker models with Scatter glyphs. For example: instead of Asterisk(), use Scatter(marker="asterisk").

For backwards compatibility, all markers in this module currently link to their respective replacements using the Scatter glyph.

By definition, all markers accept the following set of properties:

  • x, y position

  • size in pixels

  • line, fill, and hatch properties

  • angle

The asterisk, cross, dash, dot, x, and y only render line components. Those markers ignore any values that are passed to the fill and hatch properties.

Note

When you draw circle markers with Scatter, you can only assign a size in screen units (by passing a number of pixels to the size property). In case you want to define the radius of circles in data units, use the Circle glyph instead of the Scatter glyph.

Asterisk

Asterisk(*args, **kwargs)[source]

Render asterisk ‘*’ markers. (deprecated)

Circle

Circle(*args, **kwargs) Model[source]

Render circle markers.

Example

import numpy as np

from bokeh.io import curdoc, show
from bokeh.models import Circle, ColumnDataSource, Grid, LinearAxis, Plot

N = 9
x = np.linspace(-2, 2, N)
y = x**2
sizes = np.linspace(10, 20, N)

source = ColumnDataSource(dict(x=x, y=y, sizes=sizes))

plot = Plot(
    title=None, width=300, height=300,
    min_border=0, toolbar_location=None)

glyph = Circle(x="x", y="y", size="sizes", line_color="#3288bd", fill_color="white", line_width=3)
plot.add_glyph(source, glyph)

xaxis = LinearAxis()
plot.add_layout(xaxis, 'below')

yaxis = LinearAxis()
plot.add_layout(yaxis, 'left')

plot.add_layout(Grid(dimension=0, ticker=xaxis.ticker))
plot.add_layout(Grid(dimension=1, ticker=yaxis.ticker))

curdoc().add_root(plot)

show(plot)

CircleCross

CircleCross(*args, **kwargs)[source]

Render circle markers with a ‘+’ cross through the center. (deprecated)

CircleDot

CircleDot(*args, **kwargs)[source]

Render circle markers with center dots. (deprecated)

CircleX

CircleX(*args, **kwargs)[source]

Render circle markers with an ‘X’ cross through the center. (deprecated)

CircleY

CircleY(*args, **kwargs)[source]

Render circle markers with an ‘Y’ cross through the center. (deprecated)

Cross

Cross(*args, **kwargs)[source]

Render ‘+’ cross markers. (deprecated)

Dash

Dash(*args, **kwargs)[source]

Render dash markers. (deprecated)

Diamond

Diamond(*args, **kwargs)[source]

Render diamond markers. (deprecated)

DiamondCross

DiamondCross(*args, **kwargs)[source]

Render diamond markers with a ‘+’ cross through the center. (deprecated)

DiamondDot

DiamondDot(*args, **kwargs)[source]

Render diamond markers with center dots. (deprecated)

Dot

Dot(*args, **kwargs)[source]

Render dots (one-quarter radius circles). (deprecated)

Hex

Hex(*args, **kwargs)[source]

Render hexagon markers. (deprecated)

HexDot

HexDot(*args, **kwargs)[source]

Render hexagon markers with center dots. (deprecated)

InvertedTriangle

InvertedTriangle(*args, **kwargs)[source]

Render upside-down triangle markers. (deprecated)

Marker

Marker(*args, **kwargs) Model[source]

Base class for glyphs that are simple markers with line and fill properties, located at an (x, y) location with a specified size.

Note

For simplicity, all markers have both line and fill properties declared, however some marker types (asterisk, cross, x) only draw lines. For these markers, the fill values are simply ignored.

Note

This is an abstract base class used to help organize the hierarchy of Bokeh model types. It is not useful to instantiate on its own.

Plus

Plus(*args, **kwargs)[source]

Render filled plus markers

Scatter

Scatter(*args, **kwargs) Model[source]

Render scatter markers selected from a predefined list of designs.

Use Scatter to draw any of Bokeh’s built-in marker types: asterisk, circle, circle_cross, circle_dot, circle_x, circle_y, cross, dash, diamond, diamond_cross, diamond_dot, dot, hex, hex_dot, inverted_triangle, plus, square, square_cross, square_dot, square_pin, square_x, star, star_dot, triangle, triangle_dot, triangle_pin, x, or y. This collection is available in MarkerType.

Bokeh’s built-in markers consist of a set of base markers, most of which can be combined with different kinds of additional visual features:

You can select marker types in two ways:

  • To draw the same marker for all values, use the marker attribute to specify the name of a specific marker. For example:

    glyph = Scatter(x="x", y="y", size="sizes", marker="square")
    plot.add_glyph(source, glyph)
    

    This will render square markers for all points.

  • Alternatively, to use marker types specified in a data source column, assign the column name to the marker attribute. For example:

    # source.data['markers'] = ["circle", "square", "circle", ... ]
    
    glyph = Scatter(x="x", y="y", size="sizes", marker="markers")
    plot.add_glyph(source, glyph)
    

Note

When you draw circle markers with Scatter, you can only assign a size in screen units (by passing a number of pixels to the size property). In case you want to define the radius of circles in data units, use the Circle glyph instead of the Scatter glyph.

Note

Scatter markers with multiple marker types may be drawn in a different order when using the WebGL output backend. This is an explicit trade-off made in the interests of performance.

Example

import numpy as np

from bokeh.core.enums import MarkerType
from bokeh.io import curdoc, show
from bokeh.models import ColumnDataSource, Grid, LinearAxis, Plot, Scatter

N = len(MarkerType)
x = np.linspace(-2, 2, N)
y = x**2
markers = list(MarkerType)

source = ColumnDataSource(dict(x=x, y=y, markers=markers))

plot = Plot(
    title=None, width=300, height=300,
    min_border=0, toolbar_location=None)

glyph = Scatter(x="x", y="y", size=20, fill_color="#74add1", marker="markers")
plot.add_glyph(source, glyph)

xaxis = LinearAxis()
plot.add_layout(xaxis, 'below')

yaxis = LinearAxis()
plot.add_layout(yaxis, 'left')

plot.add_layout(Grid(dimension=0, ticker=xaxis.ticker))
plot.add_layout(Grid(dimension=1, ticker=yaxis.ticker))

curdoc().add_root(plot)

show(plot)

Square

Square(*args, **kwargs)[source]

Render square markers. (deprecated)

SquareCross

SquareCross(*args, **kwargs)[source]

Render square markers with a ‘+’ cross through the center. (deprecated)

SquareDot

SquareDot(*args, **kwargs)[source]

Render square markers with center dots. (deprecated)

SquarePin

SquarePin(*args, **kwargs)[source]

Render pin-cushion square markers. (deprecated)

SquareX

SquareX(*args, **kwargs)[source]

Render square markers with an ‘X’ cross through the center. (deprecated)

Star

Star(*args, **kwargs)[source]

Render star markers. (deprecated)

StarDot

StarDot(*args, **kwargs)[source]

Render star markers with center dots. (deprecated)

Triangle

Triangle(*args, **kwargs)[source]

Render triangle markers. (deprecated)

TriangleDot

TriangleDot(*args, **kwargs)[source]

Render triangle markers with center dots. (deprecated)

TrianglePin

TrianglePin(*args, **kwargs)[source]

Render pin-cushion triangle markers. (deprecated)

X

X(*args, **kwargs)[source]

Render ‘X’ markers. (deprecated)

Y

Y(*args, **kwargs)[source]

Render ‘Y’ markers. (deprecated)