annotators Module#

annotators Module#

class holoviews.annotators.Annotator(object=None, **params)[source]#

Bases: PaneBase

An Annotator allows drawing, editing and annotating a specific type of element. Each Annotator consists of the plot to draw and edit the element and the editor, which contains a list of tables, which make it possible to annotate each object in the element with additional properties defined in the annotations.

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, background, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout

object = param.ClassSelector(allow_None=True, allow_refs=True, class_=<class ‘holoviews.core.element.Element’>, label=’Object’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f8f68810490>)

The Element to edit and annotate.

annotations = param.ClassSelector(allow_refs=False, class_=(<class ‘dict’>, <class ‘list’>), default=[], label=’Annotations’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f8f68810f10>)

Annotations to associate with each object.

default_opts = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={‘responsive’: True, ‘min_height’: 400, ‘padding’: 0.1, ‘framewise’: True}, label=’Default opts’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f8f68813880>)

Opts to apply to the element.

empty_value = param.Parameter(allow_None=True, allow_refs=False, label=’Empty value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f8f68811e10>)

The value to insert on annotation columns when drawing a new element.

num_objects = param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), inclusive_bounds=(True, True), label=’Num objects’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f8f68813e80>)

The maximum number of objects to draw.

table_transforms = param.HookList(allow_refs=False, bounds=(0, None), default=[], label=’Table transforms’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f8f68813b80>)

Transform(s) to apply to element when converting data to Table. The functions should accept the Annotator and the transformed element as input.

table_opts = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={‘editable’: True, ‘width’: 400}, label=’Table opts’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f8f68813e50>)

Opts to apply to the editor table(s).

app(notebook_url: str = 'localhost:8888', port: int = 0) Server[source]#

Displays a bokeh server app inline in the notebook.

Arguments#

notebook_url: str

URL to the notebook server

port: int (optional, default=0)

Allows specifying a specific port

classmethod applies(obj)[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Optional[Any] = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

classmethod compose(*annotators)[source]#

Composes multiple Annotator instances and elements

The composed Panel will contain all the elements in the supplied Annotators and Tabs containing all editors.

Args:

annotators: Annotator objects or elements to compose

Returns:

A new Panel consisting of the overlaid plots and tables

controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel[source]#

Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.

Arguments#

parameters: list(str)

An explicit list of parameters to return controls for.

jslink: bool

Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.

kwargs: dict

Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None[source]#

Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) Type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Optional[Document] = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

Returns the bokeh model corresponding to this panel object

jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback[source]#

Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.

Arguments#

args: dict

A mapping of objects to make available to the JS callback

**callbacks: dict

A mapping between properties on the source model and the code to execute when that property changes

Returns#

callback: Callback

The Callback which can be used to disable the callback.

Links properties on the this Reactive object to those on the target Reactive object in JS code.

Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.

Arguments#

target: panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned

The target to link the value to.

code: dict

Custom code which will be executed when the widget value changes.

args: dict

A mapping of objects to make available to the JS callback

bidirectional: boolean

Whether to link source and target bi-directionally

**links: dict

A mapping between properties on the source model and the target model property to link it to.

Returns#

link: GenericLink

The GenericLink which can be used unlink the widget and the target model.

Links the parameters on this Reactive object to attributes on the target Parameterized object.

Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.

Arguments#

target: param.Parameterized

The target object of the link.

callbacks: dict | None

Maps from a parameter in the source object to a callback.

bidirectional: bool

Whether to link source and target bi-directionally

**links: dict

Maps between parameters on this object to the parameters on the supplied object.

pprint() None[source]#

Prints a compositional repr of the class.

save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources: Optional[Resources] = None, template: Optional[Union[str, Template]] = None, template_variables: Dict[str, Any] = {}, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: Optional[bool] = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

filename: str or file-like object

Filename to save the plot to

title: string

Optional title for the plot

resources: bokeh resources

One of the valid bokeh.resources (e.g. CDN or INLINE)

template:

passed to underlying io.save

template_variables:

passed to underlying io.save

embed: bool

Whether the state space should be embedded in the saved file.

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

embed_json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for the auto-generated json directory

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=True)

Whether to report progress

embed_states: dict (default={})

A dictionary specifying the widget values to embed for each widget

as_png: boolean (default=None)

To save as a .png. If None save_png will be true if filename is string and ends with png.

select(selector=None)[source]#

Iterates over the Viewable and any potential children in the applying the Selector.

Arguments#

selector: type or callable or None

The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.

Returns#

viewables: list(Viewable)

servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin[source]#

Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

area: str (deprecated)

The area of a template to add the component too. Only has an effect if pn.config.template has been set.

target: str

Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.

Returns#

The Panel object itself

server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server[source]#

Starts a Bokeh server and displays the Viewable in a new tab.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

The address the server should listen on for HTTP requests.

websocket_origin: str or list(str) (optional)

A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.

threaded: boolean (optional, default=False)

Whether to launch the Server on a separate thread, allowing interactive use.

verbose: boolean (optional, default=True)

Whether to print the address and port

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class holoviews.annotators.CurveAnnotator(object=None, **params)[source]#

Bases: _GeomAnnotator

Annotator which allows editing a Curve element and associating values with each vertex using a Table.

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, background, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout

holoviews.annotators.Annotator: annotations, empty_value, num_objects, table_transforms, table_opts

object = param.ClassSelector(allow_None=True, allow_refs=True, class_=<class ‘holoviews.element.chart.Curve’>, label=’Object’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f8f6872f0d0>)

Points element to edit and annotate.

default_opts = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={‘responsive’: True, ‘min_height’: 400, ‘padding’: 0.1, ‘framewise’: True}, label=’Default opts’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f8f6872fdc0>)

Opts to apply to the element.

vertex_style = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={‘size’: 10}, label=’Vertex style’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f8f6872e620>)

Options to apply to vertices during drawing and editing.

app(notebook_url: str = 'localhost:8888', port: int = 0) Server[source]#

Displays a bokeh server app inline in the notebook.

Arguments#

notebook_url: str

URL to the notebook server

port: int (optional, default=0)

Allows specifying a specific port

classmethod applies(obj)[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Optional[Any] = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

classmethod compose(*annotators)[source]#

Composes multiple Annotator instances and elements

The composed Panel will contain all the elements in the supplied Annotators and Tabs containing all editors.

Args:

annotators: Annotator objects or elements to compose

Returns:

A new Panel consisting of the overlaid plots and tables

controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel[source]#

Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.

Arguments#

parameters: list(str)

An explicit list of parameters to return controls for.

jslink: bool

Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.

kwargs: dict

Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None[source]#

Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) Type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Optional[Document] = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

Returns the bokeh model corresponding to this panel object

jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback[source]#

Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.

Arguments#

args: dict

A mapping of objects to make available to the JS callback

**callbacks: dict

A mapping between properties on the source model and the code to execute when that property changes

Returns#

callback: Callback

The Callback which can be used to disable the callback.

Links properties on the this Reactive object to those on the target Reactive object in JS code.

Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.

Arguments#

target: panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned

The target to link the value to.

code: dict

Custom code which will be executed when the widget value changes.

args: dict

A mapping of objects to make available to the JS callback

bidirectional: boolean

Whether to link source and target bi-directionally

**links: dict

A mapping between properties on the source model and the target model property to link it to.

Returns#

link: GenericLink

The GenericLink which can be used unlink the widget and the target model.

Links the parameters on this Reactive object to attributes on the target Parameterized object.

Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.

Arguments#

target: param.Parameterized

The target object of the link.

callbacks: dict | None

Maps from a parameter in the source object to a callback.

bidirectional: bool

Whether to link source and target bi-directionally

**links: dict

Maps between parameters on this object to the parameters on the supplied object.

pprint() None[source]#

Prints a compositional repr of the class.

save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources: Optional[Resources] = None, template: Optional[Union[str, Template]] = None, template_variables: Dict[str, Any] = {}, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: Optional[bool] = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

filename: str or file-like object

Filename to save the plot to

title: string

Optional title for the plot

resources: bokeh resources

One of the valid bokeh.resources (e.g. CDN or INLINE)

template:

passed to underlying io.save

template_variables:

passed to underlying io.save

embed: bool

Whether the state space should be embedded in the saved file.

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

embed_json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for the auto-generated json directory

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=True)

Whether to report progress

embed_states: dict (default={})

A dictionary specifying the widget values to embed for each widget

as_png: boolean (default=None)

To save as a .png. If None save_png will be true if filename is string and ends with png.

select(selector=None)[source]#

Iterates over the Viewable and any potential children in the applying the Selector.

Arguments#

selector: type or callable or None

The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.

Returns#

viewables: list(Viewable)

servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin[source]#

Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

area: str (deprecated)

The area of a template to add the component too. Only has an effect if pn.config.template has been set.

target: str

Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.

Returns#

The Panel object itself

server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server[source]#

Starts a Bokeh server and displays the Viewable in a new tab.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

The address the server should listen on for HTTP requests.

websocket_origin: str or list(str) (optional)

A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.

threaded: boolean (optional, default=False)

Whether to launch the Server on a separate thread, allowing interactive use.

verbose: boolean (optional, default=True)

Whether to print the address and port

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class holoviews.annotators.PathAnnotator(object=None, **params)[source]#

Bases: Annotator

Annotator which allows drawing and editing Paths and associating values with each path and each vertex of a path using a table.

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, background, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout

holoviews.annotators.Annotator: annotations, default_opts, empty_value, num_objects, table_transforms, table_opts

object = param.ClassSelector(allow_None=True, allow_refs=True, class_=<class ‘holoviews.element.path.Path’>, label=’Object’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f8f68c71e40>)

Path object to edit and annotate.

edit_vertices = param.Boolean(allow_refs=False, default=True, label=’Edit vertices’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f8f68c707f0>)

Whether to add tool to edit vertices.

show_vertices = param.Boolean(allow_refs=False, default=True, label=’Show vertices’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f8f68c737c0>)

Whether to show vertices when drawing the Path.

vertex_annotations = param.ClassSelector(allow_refs=False, class_=(<class ‘dict’>, <class ‘list’>), default=[], label=’Vertex annotations’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f8f68c70ac0>)

Columns to annotate the Polygons with.

vertex_style = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={‘nonselection_alpha’: 0.5}, label=’Vertex style’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f8f68c717b0>)

Options to apply to vertices during drawing and editing.

app(notebook_url: str = 'localhost:8888', port: int = 0) Server[source]#

Displays a bokeh server app inline in the notebook.

Arguments#

notebook_url: str

URL to the notebook server

port: int (optional, default=0)

Allows specifying a specific port

classmethod applies(obj)[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Optional[Any] = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

classmethod compose(*annotators)[source]#

Composes multiple Annotator instances and elements

The composed Panel will contain all the elements in the supplied Annotators and Tabs containing all editors.

Args:

annotators: Annotator objects or elements to compose

Returns:

A new Panel consisting of the overlaid plots and tables

controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel[source]#

Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.

Arguments#

parameters: list(str)

An explicit list of parameters to return controls for.

jslink: bool

Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.

kwargs: dict

Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None[source]#

Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) Type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Optional[Document] = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

Returns the bokeh model corresponding to this panel object

jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback[source]#

Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.

Arguments#

args: dict

A mapping of objects to make available to the JS callback

**callbacks: dict

A mapping between properties on the source model and the code to execute when that property changes

Returns#

callback: Callback

The Callback which can be used to disable the callback.

Links properties on the this Reactive object to those on the target Reactive object in JS code.

Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.

Arguments#

target: panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned

The target to link the value to.

code: dict

Custom code which will be executed when the widget value changes.

args: dict

A mapping of objects to make available to the JS callback

bidirectional: boolean

Whether to link source and target bi-directionally

**links: dict

A mapping between properties on the source model and the target model property to link it to.

Returns#

link: GenericLink

The GenericLink which can be used unlink the widget and the target model.

Links the parameters on this Reactive object to attributes on the target Parameterized object.

Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.

Arguments#

target: param.Parameterized

The target object of the link.

callbacks: dict | None

Maps from a parameter in the source object to a callback.

bidirectional: bool

Whether to link source and target bi-directionally

**links: dict

Maps between parameters on this object to the parameters on the supplied object.

pprint() None[source]#

Prints a compositional repr of the class.

save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources: Optional[Resources] = None, template: Optional[Union[str, Template]] = None, template_variables: Dict[str, Any] = {}, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: Optional[bool] = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

filename: str or file-like object

Filename to save the plot to

title: string

Optional title for the plot

resources: bokeh resources

One of the valid bokeh.resources (e.g. CDN or INLINE)

template:

passed to underlying io.save

template_variables:

passed to underlying io.save

embed: bool

Whether the state space should be embedded in the saved file.

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

embed_json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for the auto-generated json directory

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=True)

Whether to report progress

embed_states: dict (default={})

A dictionary specifying the widget values to embed for each widget

as_png: boolean (default=None)

To save as a .png. If None save_png will be true if filename is string and ends with png.

select(selector=None)[source]#

Iterates over the Viewable and any potential children in the applying the Selector.

Arguments#

selector: type or callable or None

The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.

Returns#

viewables: list(Viewable)

servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin[source]#

Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

area: str (deprecated)

The area of a template to add the component too. Only has an effect if pn.config.template has been set.

target: str

Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.

Returns#

The Panel object itself

server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server[source]#

Starts a Bokeh server and displays the Viewable in a new tab.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

The address the server should listen on for HTTP requests.

websocket_origin: str or list(str) (optional)

A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.

threaded: boolean (optional, default=False)

Whether to launch the Server on a separate thread, allowing interactive use.

verbose: boolean (optional, default=True)

Whether to print the address and port

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class holoviews.annotators.PointAnnotator(object=None, **params)[source]#

Bases: _GeomAnnotator

Annotator which allows drawing and editing Points and associating values with each point using a table.

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, background, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout

holoviews.annotators.Annotator: annotations, empty_value, num_objects, table_transforms, table_opts

object = param.ClassSelector(allow_None=True, allow_refs=True, class_=<class ‘holoviews.element.geom.Points’>, label=’Object’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f8f6872de40>)

Points element to edit and annotate.

default_opts = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={‘responsive’: True, ‘min_height’: 400, ‘padding’: 0.1, ‘size’: 10, ‘framewise’: True}, label=’Default opts’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f8f6872dc60>)

Opts to apply to the element.

app(notebook_url: str = 'localhost:8888', port: int = 0) Server[source]#

Displays a bokeh server app inline in the notebook.

Arguments#

notebook_url: str

URL to the notebook server

port: int (optional, default=0)

Allows specifying a specific port

classmethod applies(obj)[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Optional[Any] = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

classmethod compose(*annotators)[source]#

Composes multiple Annotator instances and elements

The composed Panel will contain all the elements in the supplied Annotators and Tabs containing all editors.

Args:

annotators: Annotator objects or elements to compose

Returns:

A new Panel consisting of the overlaid plots and tables

controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel[source]#

Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.

Arguments#

parameters: list(str)

An explicit list of parameters to return controls for.

jslink: bool

Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.

kwargs: dict

Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None[source]#

Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) Type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Optional[Document] = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

Returns the bokeh model corresponding to this panel object

jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback[source]#

Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.

Arguments#

args: dict

A mapping of objects to make available to the JS callback

**callbacks: dict

A mapping between properties on the source model and the code to execute when that property changes

Returns#

callback: Callback

The Callback which can be used to disable the callback.

Links properties on the this Reactive object to those on the target Reactive object in JS code.

Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.

Arguments#

target: panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned

The target to link the value to.

code: dict

Custom code which will be executed when the widget value changes.

args: dict

A mapping of objects to make available to the JS callback

bidirectional: boolean

Whether to link source and target bi-directionally

**links: dict

A mapping between properties on the source model and the target model property to link it to.

Returns#

link: GenericLink

The GenericLink which can be used unlink the widget and the target model.

Links the parameters on this Reactive object to attributes on the target Parameterized object.

Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.

Arguments#

target: param.Parameterized

The target object of the link.

callbacks: dict | None

Maps from a parameter in the source object to a callback.

bidirectional: bool

Whether to link source and target bi-directionally

**links: dict

Maps between parameters on this object to the parameters on the supplied object.

pprint() None[source]#

Prints a compositional repr of the class.

save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources: Optional[Resources] = None, template: Optional[Union[str, Template]] = None, template_variables: Dict[str, Any] = {}, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: Optional[bool] = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

filename: str or file-like object

Filename to save the plot to

title: string

Optional title for the plot

resources: bokeh resources

One of the valid bokeh.resources (e.g. CDN or INLINE)

template:

passed to underlying io.save

template_variables:

passed to underlying io.save

embed: bool

Whether the state space should be embedded in the saved file.

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

embed_json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for the auto-generated json directory

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=True)

Whether to report progress

embed_states: dict (default={})

A dictionary specifying the widget values to embed for each widget

as_png: boolean (default=None)

To save as a .png. If None save_png will be true if filename is string and ends with png.

select(selector=None)[source]#

Iterates over the Viewable and any potential children in the applying the Selector.

Arguments#

selector: type or callable or None

The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.

Returns#

viewables: list(Viewable)

servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin[source]#

Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

area: str (deprecated)

The area of a template to add the component too. Only has an effect if pn.config.template has been set.

target: str

Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.

Returns#

The Panel object itself

server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server[source]#

Starts a Bokeh server and displays the Viewable in a new tab.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

The address the server should listen on for HTTP requests.

websocket_origin: str or list(str) (optional)

A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.

threaded: boolean (optional, default=False)

Whether to launch the Server on a separate thread, allowing interactive use.

verbose: boolean (optional, default=True)

Whether to print the address and port

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class holoviews.annotators.PolyAnnotator(object=None, **params)[source]#

Bases: PathAnnotator

Annotator which allows drawing and editing Polygons and associating values with each polygon and each vertex of a Polygon using a table.

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, background, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout

holoviews.annotators.Annotator: annotations, default_opts, empty_value, num_objects, table_transforms, table_opts

holoviews.annotators.PathAnnotator: edit_vertices, show_vertices, vertex_annotations, vertex_style

object = param.ClassSelector(allow_None=True, allow_refs=True, class_=<class ‘holoviews.element.path.Polygons’>, label=’Object’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f8f68b56560>)

Polygon element to edit and annotate.

app(notebook_url: str = 'localhost:8888', port: int = 0) Server[source]#

Displays a bokeh server app inline in the notebook.

Arguments#

notebook_url: str

URL to the notebook server

port: int (optional, default=0)

Allows specifying a specific port

classmethod applies(obj)[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Optional[Any] = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

classmethod compose(*annotators)[source]#

Composes multiple Annotator instances and elements

The composed Panel will contain all the elements in the supplied Annotators and Tabs containing all editors.

Args:

annotators: Annotator objects or elements to compose

Returns:

A new Panel consisting of the overlaid plots and tables

controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel[source]#

Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.

Arguments#

parameters: list(str)

An explicit list of parameters to return controls for.

jslink: bool

Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.

kwargs: dict

Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None[source]#

Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) Type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Optional[Document] = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

Returns the bokeh model corresponding to this panel object

jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback[source]#

Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.

Arguments#

args: dict

A mapping of objects to make available to the JS callback

**callbacks: dict

A mapping between properties on the source model and the code to execute when that property changes

Returns#

callback: Callback

The Callback which can be used to disable the callback.

Links properties on the this Reactive object to those on the target Reactive object in JS code.

Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.

Arguments#

target: panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned

The target to link the value to.

code: dict

Custom code which will be executed when the widget value changes.

args: dict

A mapping of objects to make available to the JS callback

bidirectional: boolean

Whether to link source and target bi-directionally

**links: dict

A mapping between properties on the source model and the target model property to link it to.

Returns#

link: GenericLink

The GenericLink which can be used unlink the widget and the target model.

Links the parameters on this Reactive object to attributes on the target Parameterized object.

Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.

Arguments#

target: param.Parameterized

The target object of the link.

callbacks: dict | None

Maps from a parameter in the source object to a callback.

bidirectional: bool

Whether to link source and target bi-directionally

**links: dict

Maps between parameters on this object to the parameters on the supplied object.

pprint() None[source]#

Prints a compositional repr of the class.

save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources: Optional[Resources] = None, template: Optional[Union[str, Template]] = None, template_variables: Dict[str, Any] = {}, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: Optional[bool] = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

filename: str or file-like object

Filename to save the plot to

title: string

Optional title for the plot

resources: bokeh resources

One of the valid bokeh.resources (e.g. CDN or INLINE)

template:

passed to underlying io.save

template_variables:

passed to underlying io.save

embed: bool

Whether the state space should be embedded in the saved file.

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

embed_json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for the auto-generated json directory

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=True)

Whether to report progress

embed_states: dict (default={})

A dictionary specifying the widget values to embed for each widget

as_png: boolean (default=None)

To save as a .png. If None save_png will be true if filename is string and ends with png.

select(selector=None)[source]#

Iterates over the Viewable and any potential children in the applying the Selector.

Arguments#

selector: type or callable or None

The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.

Returns#

viewables: list(Viewable)

servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin[source]#

Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

area: str (deprecated)

The area of a template to add the component too. Only has an effect if pn.config.template has been set.

target: str

Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.

Returns#

The Panel object itself

server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server[source]#

Starts a Bokeh server and displays the Viewable in a new tab.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

The address the server should listen on for HTTP requests.

websocket_origin: str or list(str) (optional)

A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.

threaded: boolean (optional, default=False)

Whether to launch the Server on a separate thread, allowing interactive use.

verbose: boolean (optional, default=True)

Whether to print the address and port

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class holoviews.annotators.RectangleAnnotator(object=None, **params)[source]#

Bases: _GeomAnnotator

Annotator which allows drawing and editing Rectangles and associating values with each point using a table.

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, background, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout

holoviews.annotators.Annotator: annotations, empty_value, num_objects, table_transforms, table_opts

holoviews.annotators._GeomAnnotator: default_opts

object = param.ClassSelector(allow_None=True, allow_refs=True, class_=<class ‘holoviews.element.geom.Rectangles’>, label=’Object’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f8f68b57ee0>)

Points element to edit and annotate.

app(notebook_url: str = 'localhost:8888', port: int = 0) Server[source]#

Displays a bokeh server app inline in the notebook.

Arguments#

notebook_url: str

URL to the notebook server

port: int (optional, default=0)

Allows specifying a specific port

classmethod applies(obj)[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Optional[Any] = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

classmethod compose(*annotators)[source]#

Composes multiple Annotator instances and elements

The composed Panel will contain all the elements in the supplied Annotators and Tabs containing all editors.

Args:

annotators: Annotator objects or elements to compose

Returns:

A new Panel consisting of the overlaid plots and tables

controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel[source]#

Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.

Arguments#

parameters: list(str)

An explicit list of parameters to return controls for.

jslink: bool

Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.

kwargs: dict

Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None[source]#

Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) Type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Optional[Document] = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

Returns the bokeh model corresponding to this panel object

jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback[source]#

Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.

Arguments#

args: dict

A mapping of objects to make available to the JS callback

**callbacks: dict

A mapping between properties on the source model and the code to execute when that property changes

Returns#

callback: Callback

The Callback which can be used to disable the callback.

Links properties on the this Reactive object to those on the target Reactive object in JS code.

Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.

Arguments#

target: panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned

The target to link the value to.

code: dict

Custom code which will be executed when the widget value changes.

args: dict

A mapping of objects to make available to the JS callback

bidirectional: boolean

Whether to link source and target bi-directionally

**links: dict

A mapping between properties on the source model and the target model property to link it to.

Returns#

link: GenericLink

The GenericLink which can be used unlink the widget and the target model.

Links the parameters on this Reactive object to attributes on the target Parameterized object.

Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.

Arguments#

target: param.Parameterized

The target object of the link.

callbacks: dict | None

Maps from a parameter in the source object to a callback.

bidirectional: bool

Whether to link source and target bi-directionally

**links: dict

Maps between parameters on this object to the parameters on the supplied object.

pprint() None[source]#

Prints a compositional repr of the class.

save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources: Optional[Resources] = None, template: Optional[Union[str, Template]] = None, template_variables: Dict[str, Any] = {}, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: Optional[bool] = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

filename: str or file-like object

Filename to save the plot to

title: string

Optional title for the plot

resources: bokeh resources

One of the valid bokeh.resources (e.g. CDN or INLINE)

template:

passed to underlying io.save

template_variables:

passed to underlying io.save

embed: bool

Whether the state space should be embedded in the saved file.

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

embed_json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for the auto-generated json directory

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=True)

Whether to report progress

embed_states: dict (default={})

A dictionary specifying the widget values to embed for each widget

as_png: boolean (default=None)

To save as a .png. If None save_png will be true if filename is string and ends with png.

select(selector=None)[source]#

Iterates over the Viewable and any potential children in the applying the Selector.

Arguments#

selector: type or callable or None

The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.

Returns#

viewables: list(Viewable)

servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin[source]#

Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

area: str (deprecated)

The area of a template to add the component too. Only has an effect if pn.config.template has been set.

target: str

Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.

Returns#

The Panel object itself

server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server[source]#

Starts a Bokeh server and displays the Viewable in a new tab.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

The address the server should listen on for HTTP requests.

websocket_origin: str or list(str) (optional)

A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.

threaded: boolean (optional, default=False)

Whether to launch the Server on a separate thread, allowing interactive use.

verbose: boolean (optional, default=True)

Whether to print the address and port

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class holoviews.annotators.annotate(*, annotations, annotator, edit_vertices, empty_value, num_objects, show_vertices, table_opts, table_transforms, vertex_annotations, vertex_style, name)[source]#

Bases: ParameterizedFunction

The annotate function allows drawing, editing and annotating any given Element (if it is supported). The annotate function returns a Layout of the editable plot and an Overlay of table(s), which allow editing the data of the element. The edited and annotated data may be accessed using the element and selected properties.

annotator = param.Parameter(allow_None=True, allow_refs=False, label=’Annotator’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f8f68b57370>)

The current Annotator instance.

annotations = param.ClassSelector(allow_refs=False, class_=(<class ‘dict’>, <class ‘list’>), default=[], label=’Annotations’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f8f65eb03d0>)

Annotations to associate with each object.

edit_vertices = param.Boolean(allow_refs=False, default=True, label=’Edit vertices’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f8f68b574c0>)

Whether to add tool to edit vertices.

empty_value = param.Parameter(allow_None=True, allow_refs=False, label=’Empty value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f8f65eb03d0>)

The value to insert on annotation columns when drawing a new element.

num_objects = param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), inclusive_bounds=(True, True), label=’Num objects’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f8f68b55450>)

The maximum number of objects to draw.

show_vertices = param.Boolean(allow_refs=False, default=True, label=’Show vertices’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f8f65eb03d0>)

Whether to show vertices when drawing the Path.

table_transforms = param.HookList(allow_refs=False, bounds=(0, None), default=[], label=’Table transforms’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f8f68b577c0>)

Transform(s) to apply to element when converting data to Table. The functions should accept the Annotator and the transformed element as input.

table_opts = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={‘editable’: True, ‘width’: 400}, label=’Table opts’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f8f65eb03d0>)

Opts to apply to the editor table(s).

vertex_annotations = param.ClassSelector(allow_refs=False, class_=(<class ‘dict’>, <class ‘list’>), default=[], label=’Vertex annotations’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f8f68b54df0>)

Columns to annotate the Polygons with.

vertex_style = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={‘nonselection_alpha’: 0.5}, label=’Vertex style’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f8f65eb03d0>)

Options to apply to vertices during drawing and editing.

classmethod compose(*annotators)[source]#

Composes multiple annotator layouts and elements

The composed Layout will contain all the elements in the supplied annotators and an overlay of all editor tables.

Args:

annotators: Annotator layouts or elements to compose

Returns:

A new layout consisting of the overlaid plots and tables

classmethod instance(**params)[source]#

Return an instance of this class, copying parameters from any existing instance provided.

holoviews.annotators.preprocess(function, current=None)[source]#

Turns a param.depends watch call into a preprocessor method, i.e. skips all downstream events triggered by it. NOTE: This is a temporary hack while the addition of preprocessors

in param is under discussion. This only works for the first method which depends on a particular parameter. (see pyviz/param#332)