How to set the plot object name?

92 Views Asked by At

In here, it says we can select the plot object by name.

# These two are equivalent
p.select({"type": HoverTool})
p.select(HoverTool)

# These two are also equivalent
p.select({"name": "mycircle"})
p.select("mycircle")

# Keyword arguments can be supplied in place of selector dict
p.select({"name": "foo", "type": HoverTool})
p.select(name="foo", type=HoverTool)

E.g. fig.circle(x, y) Then we can select the circle marker from fig.select(Circle).

However, I am a bit interested in the name parameter. How do we set the name of each model so it is easy to query?

1

There are 1 best solutions below

1
On BEST ANSWER

The PlotObject object that all of the models/glyphs are subclassed from have a "name" attr, so you can add name='foo' as an argument when creating a plot object.

(source: https://github.com/bokeh/bokeh/blob/master/bokeh/plot_object.py)

This is an example of naming some models and passing their names to the HoverTool to select them:

http://nbviewer.ipython.org/urls/gist.githubusercontent.com/canavandl/7bae1a47e40e4d44b5da/raw/named_objects_example.ipynb