holoviews.util package#
Submodules#
Module contents#
- class holoviews.util.Dynamic(*, kwargs, link_dataset, link_inputs, operation, shared_data, streams, name)[source]#
Bases:
ParameterizedFunction
Dynamically applies a callable to the Elements in any HoloViews object. Will return a DynamicMap wrapping the original map object, which will lazily evaluate when a key is requested. By default Dynamic applies a no-op, making it useful for converting HoloMaps to a DynamicMap.
Any supplied kwargs will be passed to the callable and any streams will be instantiated on the returned DynamicMap. If the supplied operation is a method on a parameterized object which was decorated with parameter dependencies Dynamic will automatically create a stream to watch the parameter changes. This default behavior may be disabled by setting watch=False.
Parameter Definitions
operation = Callable(label='Operation')
Operation or user-defined callable to apply dynamically
kwargs = Dict(class_=<class 'dict'>, default={}, label='Kwargs')
Keyword arguments passed to the function.
link_inputs = Boolean(default=True, label='Link inputs')
If Dynamic is applied to another DynamicMap, determines whether linked streams and links attached to its Callable inputs are transferred to the output of the utility. For example if the Dynamic utility is applied to a DynamicMap with an RangeXY, this switch determines whether the corresponding visualization should update this stream with range changes originating from the newly generated axes.
link_dataset = Boolean(default=True, label='Link dataset')
Determines whether the output of the operation should inherit the .dataset property of the input to the operation. Helpful for tracking data providence for user supplied functions, which do not make use of the clone method. Should be disabled for operations where the output is not derived from the input and instead depends on some external state.
shared_data = Boolean(default=False, label='Shared data')
Whether the cloned DynamicMap will share the same cache.
streams = ClassSelector(class_=(<class 'list'>, <class 'dict'>), default=[], label='Streams')
List of streams to attach to the returned DynamicMap
- class holoviews.util.OptsMeta(name, bases, dict_)[source]#
Bases:
ParameterizedMetaclass
Improve error message when running something like : ‘hv.opts.Curve()’ without a plotting backend.
- holoviews.util.examples(path='holoviews-examples', verbose=False, force=False, root='/Users/runner/work/holoviews/holoviews/holoviews/util/__init__.py')[source]#
Copies the notebooks to the supplied path.
- class holoviews.util.extension(*, name)[source]#
Bases:
extension
Helper utility used to load holoviews extensions. These can be plotting extensions, element extensions or anything else that can be registered to work with HoloViews.
The plotting extension is the most commonly used and is used to select the plotting backend. The plotting extension can be loaded using the backend name, e.g. ‘bokeh’, ‘matplotlib’ or ‘plotly’.
Examples#
Activate the bokeh plotting extension:
`python import holoviews as hv hv.extension("bokeh") `
Parameter Definitions
- class holoviews.util.opts(*args, **params)[source]#
Bases:
ParameterizedFunction
Utility function to set options at the global level or to provide an Options object that can be used with the .options method of an element or container.
Option objects can be generated and validated in a tab-completable way (in appropriate environments such as Jupyter notebooks) using completers such as opts.Curve, opts.Image, opts.Overlay, etc.
To set opts globally you can pass these option objects into opts.defaults:
opts.defaults(*options)
For instance:
opts.defaults(opts.Curve(color=’red’))
To set opts on a specific object, you can supply these option objects to the .options method.
For instance:
curve = hv.Curve([1,2,3]) curve.options(opts.Curve(color=’red’))
The options method also accepts lists of Option objects.
Parameter Definitions
strict = Boolean(default=False, label='Strict')
Whether to be strict about the options specification. If not set to strict (default), any invalid keywords are simply skipped. If strict, invalid keywords prevent the options being applied.
- classmethod apply_groups(obj, options=None, backend=None, clone=True, **kwargs)[source]#
Applies nested options definition grouped by type.
Applies options on an object or nested group of objects, returning a new object with the options applied. This method accepts the separate option namespaces explicitly (i.e. ‘plot’, ‘style’, and ‘norm’).
If the options are to be set directly on the object a simple format may be used, e.g.:
- opts.apply_groups(obj, style={‘cmap’: ‘viridis’},
plot={‘show_title’: False})
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
- opts.apply_groups(obj, {‘Image’: {‘plot’: {‘show_title’: False},
‘style’: {‘cmap’: ‘viridis}}})
If no opts are supplied all options on the object will be reset.
Parameters#
- optionsdict
Options specification Options specification should be indexed by type[.group][.label] or option type (‘plot’, ‘style’, ‘norm’).
- backendoptional
Backend to apply options to Defaults to current selected backend
- clonebool, optional
Whether to clone object Options can be applied inplace with clone=False
- **kwargs: Keywords of options by type
Applies options directly to the object by type (e.g. ‘plot’, ‘style’, ‘norm’) specified as dictionaries.
Returns#
Returns the object or a clone with the options applied
- class holoviews.util.output(*args, **params)[source]#
Bases:
ParameterizedFunction
Helper used to set HoloViews display options. Arguments are supplied as a series of keywords in any order:
backend : The backend used by HoloViews fig : The static figure format holomap : The display type for holomaps widgets : The widget mode for widgets fps : The frames per second used for animations max_frames : The max number of frames rendered (default 500) size : The percentage size of displayed output dpi : The rendered dpi of the figure filename : The filename of the saved output, if any (default None) info : The information to page about the displayed objects (default False) css : Optional css style attributes to apply to the figure image tag widget_location : The position of the widgets relative to the plot
Parameter Definitions
- holoviews.util.render(obj, backend=None, **kwargs)[source]#
Renders the HoloViews object to the corresponding object in the specified backend, e.g. a Matplotlib or Bokeh figure.
The backend defaults to the currently declared default backend. The resulting object can then be used with other objects in the specified backend. For instance, if you want to make a multi-part Bokeh figure using a plot type only available in HoloViews, you can use this function to return a Bokeh figure that you can use like any hand-constructed Bokeh figure in a Bokeh layout.
Parameters#
- objHoloViews object
The HoloViews object to render
- backendstring
A valid HoloViews rendering backend
- **kwargs: dict
Additional keyword arguments passed to the renderer, e.g. fps for animations
Returns#
- rendered :
The rendered representation of the HoloViews object, e.g. if backend=’matplotlib’ a matplotlib Figure or FuncAnimation
- holoviews.util.renderer(name)[source]#
Helper utility to access the active renderer for a given extension.
- holoviews.util.save(obj, filename, fmt='auto', backend=None, resources='cdn', toolbar=None, title=None, **kwargs)[source]#
Saves the supplied object to file.
The available output formats depend on the backend being used. By default and if the filename is a string the output format will be inferred from the file extension. Otherwise an explicit format will need to be specified. For ambiguous file extensions such as html it may be necessary to specify an explicit fmt to override the default, e.g. in the case of ‘html’ output the widgets will default to fmt=’widgets’, which may be changed to scrubber widgets using fmt=’scrubber’.
Parameters#
- objHoloViews object
The HoloViews object to save to file
- filenamestring or IO object
The filename or BytesIO/StringIO object to save to
- fmtstring
The format to save the object as, e.g. png, svg, html, or gif and if widgets are desired either ‘widgets’ or ‘scrubber’
- backendstring
A valid HoloViews rendering backend, e.g. bokeh or matplotlib
- resourcesstring or bokeh.resource.Resources
Bokeh resources used to load bokehJS components. Defaults to CDN, to embed resources inline for offline usage use ‘inline’ or bokeh.resources.INLINE.
- toolbarbool or None
Whether to include toolbars in the exported plot. If None, display the toolbar unless fmt is png and backend is bokeh. If True, always include the toolbar. If False, do not include the toolbar.
- titlestring
Custom title for exported HTML file
- **kwargs: dict
Additional keyword arguments passed to the renderer, e.g. fps for animations