__init__ Module#
__init__
Module#
HoloViews makes data analysis and visualization simple#
HoloViews lets you focus on what you are trying to explore and convey, not on the process of plotting.
HoloViews
supports a wide range of data sources including Pandas, Dask, XArray
Rapids cuDF, Streamz, Intake, Geopandas, NetworkX and Ibis. - supports the plotting backends Bokeh (default), Matplotlib and Plotly. - allows you to drop into the rest of the HoloViz ecosystem when more power or flexibility is needed.
For basic data exploration we recommend using the higher level hvPlot package, which provides the familiar Pandas .plot api. You can drop into HoloViews when needed.
To learn more check out https://holoviews.org/. To report issues or contribute go to holoviz/holoviews. To join the community go to https://discourse.holoviz.org/.
How to use HoloViews in 3 simple steps#
Work with the data source you already know and ❤️
>>> import pandas as pd
>>> station_info = pd.read_csv('https://raw.githubusercontent.com/holoviz/holoviews/main/examples/assets/station_info.csv')
Import HoloViews and configure your plotting backend
>>> import holoviews as hv
>>> hv.extension('bokeh')
Annotate your data
>>> scatter = (
... hv.Scatter(station_info, kdims='services', vdims='ridership')
... .redim(
... services=hv.Dimension("services", label='Services'),
... ridership=hv.Dimension("ridership", label='Ridership'),
... )
... .opts(size=10, color="red", responsive=True)
... )
>>> scatter
In a notebook this will display a nice scatter plot.
Note that the kdims (The key dimension(s)) represents the independent variable(s) and the vdims (value dimension(s)) the dependent variable(s).
For more check out https://holoviews.org/getting_started/Introduction.html
How to get help#
You can understand the structure of your objects by printing them.
>>> print(scatter)
:Scatter [services] (ridership)
You can get extensive documentation using hv.help.
>>> hv.help(scatter)
In a notebook or ipython environment the usual
help and ? will provide you with documentation.
TAB and SHIFT+TAB completion will help you navigate.
To ask the community go to https://discourse.holoviz.org/. To report issues go to holoviz/holoviews.
- class holoviews.__init__.AdjointLayout(data, **params)[source]#
Bases:
Layoutable
,Dimensioned
An AdjointLayout provides a convenient container to lay out some marginal plots next to a primary plot. This is often useful to display the marginal distributions of a plot next to the primary plot. AdjointLayout accepts a list of up to three elements, which are laid out as follows with the names ‘main’, ‘top’ and ‘right’:
3 | ||___________|___| | | | 1: main | | | 2: right | 1 | 2 | 3: top | | | |___________|___|
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: group, cdims, vdimskdims
= param.List(allow_refs=False, bounds=(0, None), constant=True, default=[Dimension(‘AdjointLayout’)], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12452df50>)The key dimensions defined as list of dimensions that may be used in indexing (and potential slicing) semantics. The order of the dimensions listed here determines the semantics of each component of a multi-dimensional indexing operation. Aliased with key_dimensions.
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- property ddims#
The list of deep dimensions
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
Applies to the main object in the AdjointLayout.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get(key, default=None)[source]#
Returns the viewable corresponding to the supplied string or integer based key.
- Args:
key: Numeric or string index: 0) ‘main’ 1) ‘right’ 2) ‘top’ default: Value returned if key not found
- Returns:
Indexed value or supplied default
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- property group#
Group inherited from main element
- property label#
Label inherited from main element
- property main#
Returns the main element in the AdjointLayout
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- range(dimension, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- relabel(label=None, group=None, depth=1)[source]#
Clone object and apply new group and/or label.
Applies relabeling to child up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- property right#
Returns the right marginal element in the AdjointLayout
- select(selection_specs=None, **kwargs)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
- Args:
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property top#
Returns the top marginal element in the AdjointLayout
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Annotation(data, **params)[source]#
Bases:
Element2D
An Annotation is a special type of element that is designed to be overlaid on top of any arbitrary 2D element. Annotations have neither key nor value dimensions allowing them to be overlaid over any type of data.
Note that one or more Annotations can be displayed without being overlaid on top of any other data. In such instances (by default) they will be displayed using the unit axis limits (0.0-1.0 in both directions) unless an explicit ‘extents’ parameter is supplied. The extents of the bottom Annotation in the Overlay is used when multiple Annotations are displayed together.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdims, vdimsholoviews.core.element.Element2D
: extentsgroup
= param.String(allow_refs=False, constant=True, default=’Annotation’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x124569d50>)A string describing the data wrapped by the object.
kdims
= param.List(allow_refs=False, bounds=(2, 2), default=[Dimension(‘x’), Dimension(‘y’)], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1241b0f50>)The key dimensions defined as list of dimensions that may be used in indexing (and potential slicing) semantics. The order of the dimensions listed here determines the semantics of each component of a multi-dimensional indexing operation. Aliased with key_dimensions.
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(*args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords, **kwargs)[source]#
Snap list or dict of coordinates to closest position.
- Args:
coords: List of 1D or 2D coordinates **kwargs: Coordinates specified as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- range(dimension, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reduction)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The element after reductions have been applied.
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=False, **sample_values)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_specs=None, **kwargs)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
- Args:
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Area(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
Curve
Area is a Chart element representing the area under a curve or between two curves in a 1D coordinate system. The key dimension represents the location of each coordinate along the x-axis, while the value dimension(s) represent the height of the area or the lower and upper bounds of the area between curves.
Multiple areas may be stacked by overlaying them an passing them to the stack method.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.element.Element2D
: extentsholoviews.core.data.Dataset
: datatypeholoviews.element.chart.Chart
: kdims, vdimsgroup
= param.String(allow_refs=False, constant=True, default=’Area’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x124495850>)A string describing the data wrapped by the object.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- classmethod stack(areas, baseline_name='Baseline')[source]#
Stacks an (Nd)Overlay of Area or Curve Elements by offsetting their baselines. To stack a HoloMap or DynamicMap use the map method.
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Arrow(x, y, text='', direction='<', points=40, arrowstyle='->', **params)[source]#
Bases:
Annotation
Draw an arrow to the given xy position with optional text at distance ‘points’ away. The direction of the arrow may be specified as well as the arrow head style.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdims, vdimsholoviews.core.element.Element2D
: extentsgroup
= param.String(allow_refs=False, constant=True, default=’Arrow’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12450ec10>)A string describing the data wrapped by the object.
x
= param.ClassSelector(allow_refs=False, class_=(<class ‘numbers.Number’>, <class ‘numpy.datetime64’>, <class ‘datetime.datetime’>, <class ‘datetime.date’>, <class ‘datetime.time’>, <class ‘pandas._libs.tslibs.timestamps.Timestamp’>, <class ‘pandas.core.dtypes.dtypes.DatetimeTZDtype’>, <class ‘pandas._libs.tslibs.period.Period’>, <class ‘cftime._cftime.datetime’>), default=0, label=’X’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1245e8c50>)The x-position of the arrow which make be numeric or a timestamp.
y
= param.ClassSelector(allow_refs=False, class_=(<class ‘numbers.Number’>, <class ‘numpy.datetime64’>, <class ‘datetime.datetime’>, <class ‘datetime.date’>, <class ‘datetime.time’>, <class ‘pandas._libs.tslibs.timestamps.Timestamp’>, <class ‘pandas.core.dtypes.dtypes.DatetimeTZDtype’>, <class ‘pandas._libs.tslibs.period.Period’>, <class ‘cftime._cftime.datetime’>), default=0, label=’Y’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12450ec10>)The y-position of the arrow which make be numeric or a timestamp.
text
= param.String(allow_refs=False, default=’’, label=’Text’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1245e8990>)Text associated with the arrow.
direction
= param.ObjectSelector(allow_refs=False, default=’<’, label=’Direction’, names={}, nested_refs=False, objects=[‘<’, ‘^’, ‘>’, ‘v’], rx=<param.reactive.reactive_ops object at 0x123feda10>)The cardinal direction in which the arrow is pointing. Accepted arrow directions are ‘<’, ‘^’, ‘>’ and ‘v’.
arrowstyle
= param.ObjectSelector(allow_refs=False, default=’->’, label=’Arrowstyle’, names={}, nested_refs=False, objects=[‘-’, ‘->’, ‘-[’, ‘-|>', '<->', '<|-|>’], rx=<param.reactive.reactive_ops object at 0x1245e8dd0>)The arrowstyle used to draw the arrow. Accepted arrow styles are ‘-’, ‘->’, ‘-[’, ‘-|>', '<->' and '<|-|>’
points
= param.Number(allow_refs=False, default=40, inclusive_bounds=(True, True), label=’Points’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12450eb50>)Font size of arrow text (if any).
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(*args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords, **kwargs)[source]#
Snap list or dict of coordinates to closest position.
- Args:
coords: List of 1D or 2D coordinates **kwargs: Coordinates specified as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- range(dimension, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reduction)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The element after reductions have been applied.
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=False, **sample_values)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_specs=None, **kwargs)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
- Args:
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Bars(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
Selection1DExpr
,Chart
Bars is a Chart element representing categorical observations using the height of rectangular bars. The key dimensions represent the categorical groupings of the data, but may also be used to stack the bars, while the first value dimension represents the height of each bar.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.element.Element2D
: extentsholoviews.core.data.Dataset
: datatypegroup
= param.String(allow_refs=False, constant=True, default=’Bars’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x124438fd0>)A string describing the data wrapped by the object.
kdims
= param.List(allow_refs=False, bounds=(1, 3), default=[Dimension(‘x’)], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12443a690>)The key dimension(s) of a Chart represent the independent variable(s).
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Bivariate(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
Selection2DExpr
,StatisticsElement
Bivariate elements are containers for two dimensional data, which is to be visualized as a kernel density estimate. The data should be supplied in a tabular format of x- and y-columns.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.element.Element2D
: extentsholoviews.core.data.Dataset
: datatypegroup
= param.String(allow_refs=False, constant=True, default=’Bivariate’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x124495890>)A string describing the data wrapped by the object.
kdims
= param.List(allow_refs=False, bounds=(2, 2), default=[Dimension(‘x’), Dimension(‘y’)], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1241bf990>)The key dimensions defined as list of dimensions that may be used in indexing (and potential slicing) semantics. The order of the dimensions listed here determines the semantics of each component of a multi-dimensional indexing operation. Aliased with key_dimensions.
vdims
= param.List(allow_refs=False, bounds=(0, 1), default=[Dimension(‘Density’)], label=’Vdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x124494b50>)The value dimensions defined as the list of dimensions used to describe the components of the data. If multiple value dimensions are supplied, a particular value dimension may be indexed by name after the key dimensions. Aliased with value_dimensions.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dim, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.BoundingBox(**args)[source]#
Bases:
BoundingRegion
A rectangular bounding box defined either by two points forming an axis-aligned rectangle (or simply a radius for a square).
- contains(x, y)[source]#
Returns true if the given point is contained within the bounding box, where all boundaries of the box are considered to be inclusive.
- contains_exclusive(x, y)[source]#
Return True if the given point is contained within the bounding box, where the bottom and right boundaries are considered exclusive.
- containsbb_exclusive(x)[source]#
Returns true if the given BoundingBox x is contained within the bounding box, where at least one of the boundaries of the box has to be exclusive.
- class holoviews.__init__.Bounds(*args, **kwargs)[source]#
Bases:
BaseShape
An arbitrary axis-aligned bounding rectangle defined by the (left, bottom, right, top) coordinate positions.
If supplied a single real number as input, this value will be treated as the radius of a square, zero-center box which will be used to compute the corresponding lbrt tuple.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.element.Element2D
: extentsholoviews.element.geom.Geometry
: kdims, vdimsholoviews.element.path.Path
: datatypegroup
= param.String(allow_refs=False, constant=True, default=’Bounds’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x123f6c210>)The assigned group name.
lbrt
= param.Tuple(allow_refs=False, default=(-0.5, -0.5, 0.5, 0.5), label=’Lbrt’, length=4, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12445a090>)The (left, bottom, right, top) coordinates of the bounding box.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(*args, **overrides)[source]#
Returns a clone of the object with matching parameter values containing the specified args and kwargs.
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- split(start=None, end=None, datatype=None, **kwargs)[source]#
The split method allows splitting a Path type into a list of subpaths of the same type. A start and/or end may be supplied to select a subset of paths.
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Box(*args, **kwargs)[source]#
Bases:
BaseShape
Draw a centered box of a given width at the given position with the specified aspect ratio (if any).
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.element.Element2D
: extentsholoviews.element.geom.Geometry
: kdims, vdimsholoviews.element.path.Path
: datatypegroup
= param.String(allow_refs=False, constant=True, default=’Box’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125018590>)The assigned group name.
x
= param.Number(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’X’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125056ed0>)The x-position of the box center.
y
= param.Number(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Y’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1250574d0>)The y-position of the box center.
width
= param.Number(allow_refs=False, default=1, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125056d10>)The width of the box.
height
= param.Number(allow_refs=False, default=1, inclusive_bounds=(True, True), label=’Height’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125057350>)The height of the box.
orientation
= param.Number(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Orientation’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125057090>)Orientation in the Cartesian coordinate system, the counterclockwise angle in radians between the first axis and the horizontal.
aspect
= param.Number(allow_refs=False, default=1.0, inclusive_bounds=(True, True), label=’Aspect’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125057690>)Optional multiplier applied to the box size to compute the width in cases where only the length value is set.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(*args, **overrides)[source]#
Returns a clone of the object with matching parameter values containing the specified args and kwargs.
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- split(start=None, end=None, datatype=None, **kwargs)[source]#
The split method allows splitting a Path type into a list of subpaths of the same type. A start and/or end may be supplied to select a subset of paths.
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.BoxWhisker(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
Selection1DExpr
,Dataset
,Element2D
BoxWhisker represent data as a distributions highlighting the median, mean and various percentiles. It may have a single value dimension and any number of key dimensions declaring the grouping of each violin.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.element.Element2D
: extentsholoviews.core.data.Dataset
: datatypegroup
= param.String(allow_refs=False, constant=True, default=’BoxWhisker’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1250e5c10>)A string describing the data wrapped by the object.
kdims
= param.List(allow_refs=False, bounds=(0, None), default=[], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1250e7910>)The key dimensions defined as list of dimensions that may be used in indexing (and potential slicing) semantics. The order of the dimensions listed here determines the semantics of each component of a multi-dimensional indexing operation. Aliased with key_dimensions.
vdims
= param.List(allow_refs=False, bounds=(1, 1), default=[Dimension(‘y’)], label=’Vdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1250e5c10>)The value dimensions defined as the list of dimensions used to describe the components of the data. If multiple value dimensions are supplied, a particular value dimension may be indexed by name after the key dimensions. Aliased with value_dimensions.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Callable(callable, **params)[source]#
Bases:
Parameterized
Callable allows wrapping callbacks on one or more DynamicMaps allowing their inputs (and in future outputs) to be defined. This makes it possible to wrap DynamicMaps with streams and makes it possible to traverse the graph of operations applied to a DynamicMap.
Additionally, if the memoize attribute is True, a Callable will memoize the last returned value based on the arguments to the function and the state of all streams on its inputs, to avoid calling the function unnecessarily. Note that because memoization includes the streams found on the inputs it may be disabled if the stream requires it and is triggering.
A Callable may also specify a stream_mapping which specifies the objects that are associated with interactive (i.e. linked) streams when composite objects such as Layouts are returned from the callback. This is required for building interactive, linked visualizations (for the backends that support them) when returning Layouts, NdLayouts or GridSpace objects. When chaining multiple DynamicMaps into a pipeline, the link_inputs parameter declares whether the visualization generated using this Callable will inherit the linked streams. This parameter is used as a hint by the applicable backend.
The mapping should map from an appropriate key to a list of streams associated with the selected object. The appropriate key may be a type[.group][.label] specification for Layouts, an integer index or a suitable NdLayout/GridSpace key. For more information see the DynamicMap tutorial at holoviews.org.
callable
= param.Callable(allow_None=True, allow_refs=False, constant=True, label=’Callable’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12465a5d0>)The callable function being wrapped.
inputs
= param.List(allow_refs=False, bounds=(0, None), constant=True, default=[], label=’Inputs’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x124647090>)The list of inputs the callable function is wrapping. Used to allow deep access to streams in chained Callables.
operation_kwargs
= param.Dict(allow_refs=False, class_=<class ‘dict’>, constant=True, default={}, label=’Operation kwargs’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12465a5d0>)Potential dynamic keyword arguments associated with the operation.
link_inputs
= param.Boolean(allow_refs=False, default=True, label=’Link inputs’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x124497a50>)If the Callable wraps around other DynamicMaps in its inputs, determines whether linked streams attached to the inputs are transferred to the objects returned by the Callable. For example the Callable wraps a DynamicMap with an RangeXY stream, this switch determines whether the corresponding visualization should update this stream with range changes originating from the newly generated axes.
memoize
= param.Boolean(allow_refs=False, default=True, label=’Memoize’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12465a610>)Whether the return value of the callable should be memoized based on the call arguments and any streams attached to the inputs.
operation
= param.Callable(allow_None=True, allow_refs=False, label=’Operation’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x124647290>)The function being applied by the Callable. May be used to record the transform(s) being applied inside the callback function.
stream_mapping
= param.Dict(allow_refs=False, class_=<class ‘dict’>, constant=True, default={}, label=’Stream mapping’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12465b810>)Defines how streams should be mapped to objects returned by the Callable, e.g. when it returns a Layout.
- clone(callable=None, **overrides)[source]#
Clones the Callable optionally with new settings
- Args:
callable: New callable function to wrap **overrides: Parameter overrides to apply
- Returns:
Cloned Callable object
- property noargs#
Returns True if the callable takes no arguments
- class holoviews.__init__.Chord(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
Graph
Chord is a special type of Graph which computes the locations of each node on a circle and the chords connecting them. The amount of radial angle devoted to each node and the number of chords are scaled by a weight supplied as a value dimension.
If the values are integers then the number of chords is directly scaled by the value, if the values are floats then the number of chords are apportioned such that the lowest value edge is given one chord and all other nodes are given nodes proportional to their weight.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdims, vdimsholoviews.core.element.Element2D
: extentsholoviews.core.data.Dataset
: datatypegroup
= param.String(allow_refs=False, constant=True, default=’Chord’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1251926d0>)A string describing the data wrapped by the object.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- property edgepaths#
Returns the fixed EdgePaths or computes direct connections between supplied nodes.
- classmethod from_networkx(G, positions, nodes=None, **kwargs)[source]#
Generate a HoloViews Graph from a networkx.Graph object and networkx layout function or dictionary of node positions. Any keyword arguments will be passed to the layout function. By default it will extract all node and edge attributes from the networkx.Graph but explicit node information may also be supplied. Any non-scalar attributes, such as lists or dictionaries will be ignored.
- Args:
G (networkx.Graph): Graph to convert to Graph element positions (dict or callable): Node positions
Node positions defined as a dictionary mapping from node id to (x, y) tuple or networkx layout function which computes a positions dictionary
kwargs (dict): Keyword arguments for layout function
- Returns:
Graph element
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- property nodes#
Computes the node positions the first time they are requested if no explicit node information was supplied.
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dimension, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, selection_mode='edges', **selection)[source]#
Allows selecting data by the slices, sets and scalar values along a particular dimension. The indices should be supplied as keywords mapping between the selected dimension and value. Additionally selection_specs (taking the form of a list of type.group.label strings, types or functions) may be supplied, which will ensure the selection is only applied if the specs match the selected object.
Selecting by a node dimensions selects all edges and nodes that are connected to the selected nodes. To select only edges between the selected nodes set the selection_mode to ‘nodes’.
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Collator(data=None, **params)[source]#
Bases:
NdMapping
Collator is an NdMapping type which can merge any number of HoloViews components with whatever level of nesting by inserting the Collators key dimensions on the HoloMaps. If the items in the Collator do not contain HoloMaps they will be created. Collator also supports filtering of Tree structures and dropping of constant dimensions.
Parameters inherited from:
group
= param.String(allow_refs=False, default=’Collator’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x124672c10>)A string describing the data wrapped by the object.
vdims
= param.List(allow_refs=False, bounds=(0, 0), default=[], label=’Vdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125139290>)Collator operates on HoloViews objects, if vdims are specified a value_transform function must also be supplied.
drop
= param.List(allow_refs=False, bounds=(0, None), default=[], label=’Drop’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x124672c10>)List of dimensions to drop when collating data, specified as strings.
drop_constant
= param.Boolean(allow_refs=False, default=False, label=’Drop constant’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125138c10>)Whether to demote any non-varying key dimensions to constant dimensions.
filters
= param.List(allow_refs=False, bounds=(0, None), default=[], label=’Filters’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1246737d0>)List of paths to drop when collating data, specified as strings or tuples.
progress_bar
= param.Parameter(allow_None=True, allow_refs=False, label=’Progress bar’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1245ee8d0>)The progress bar instance used to report progress. Set to None to disable progress bars.
merge_type
= param.ClassSelector(allow_refs=False, class_=<class ‘holoviews.core.ndmapping.NdMapping’>, default=<class ‘holoviews.core.spaces.HoloMap’>, label=’Merge type’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1246737d0>)value_transform
= param.Callable(allow_None=True, allow_refs=False, label=’Value transform’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125138910>)If supplied the function will be applied on each Collator value during collation. This may be used to apply an operation to the data or load references from disk before they are collated into a displayable HoloViews object.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the object
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or sequence of the same length as the existing keys.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int) Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- clone(data=None, shared_data=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- property ddims#
The list of deep dimensions
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- drop_dimension(dimensions)[source]#
Drops dimension(s) from keys
- Args:
dimensions: Dimension(s) to drop
- Returns:
Clone of object with with dropped dimension(s)
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions, container_type=None, group_type=None, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- property info#
Prints information about the Dimensioned object, including the number and type of objects contained within it and information about its dimensions.
- property last#
Returns the item highest data item along the map dimensions.
- property last_key#
Returns the last key value.
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- range(dimension, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reindex(kdims=None, force=False)[source]#
Reindexes object dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.
Reducing the number of key dimensions will discard information from the keys. All data values are accessible in the newly created object as the new labels must be sufficient to address each value uniquely.
- Args:
kdims (optional): New list of key dimensions after reindexing force (bool, optional): Whether to drop non-unique items
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- select(selection_specs=None, **kwargs)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
- Args:
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property static_dimensions#
Return all constant dimensions.
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Contours(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
Path
The Contours element is a subtype of a Path which is characterized by the fact that each path geometry may only be associated with scalar values. It supports all the same data formats as a Path but does not allow continuously varying values along the path geometry’s coordinates. Conceptually Contours therefore represent iso-contours or isoclines, i.e. a function of two variables which describes a curve along which the function has a constant value.
The canonical representation is a list of dictionaries storing the x- and y-coordinates along with any other (scalar) values:
[{‘x’: 1d-array, ‘y’: 1d-array, ‘value’: scalar}, …]
Alternatively Contours also supports a single columnar data-structure to specify an individual contour:
{‘x’: 1d-array, ‘y’: 1d-array, ‘value’: scalar, ‘continuous’: 1d-array}
Since not all formats allow storing scalar values as actual scalars arrays which are the same length as the coordinates but have only one unique value are also considered scalar. This is strictly enforced, ensuring that each path geometry represents a valid iso-contour.
The easiest way of accessing the individual geometries is using the Contours.split method, which returns each path geometry as a separate entity, while the other methods assume a flattened representation where all paths are separated by NaN values.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.element.Element2D
: extentsholoviews.element.geom.Geometry
: kdimsholoviews.element.path.Path
: datatypegroup
= param.String(allow_refs=False, constant=True, default=’Contours’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12478df50>)A string describing the data wrapped by the object.
vdims
= param.List(allow_refs=False, bounds=(0, None), constant=True, default=[], label=’Vdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125167350>)Contours optionally accept a value dimension, corresponding to the supplied values.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- split(start=None, end=None, datatype=None, **kwargs)[source]#
The split method allows splitting a Path type into a list of subpaths of the same type. A start and/or end may be supplied to select a subset of paths.
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Curve(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
Selection1DExpr
,Chart
Curve is a Chart element representing a line in a 1D coordinate system where the key dimension maps on the line x-coordinate and the first value dimension represents the height of the line along the y-axis.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.element.Element2D
: extentsholoviews.core.data.Dataset
: datatypeholoviews.element.chart.Chart
: kdims, vdimsgroup
= param.String(allow_refs=False, constant=True, default=’Curve’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12477d050>)A string describing the data wrapped by the object.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Cycle(cycle=None, **params)[source]#
Bases:
Parameterized
A simple container class that specifies cyclic options. A typical example would be to cycle the curve colors in an Overlay composed of an arbitrary number of curves. The values may be supplied as an explicit list or a key to look up in the default cycles attribute.
key
= param.String(allow_None=True, allow_refs=False, default=’default_colors’, label=’Key’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1247b0390>)The key in the default_cycles dictionary used to specify the color cycle if values is not supplied.
values
= param.List(allow_refs=False, bounds=(0, None), default=[], label=’Values’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1247b1c10>)The values the cycle will iterate over.
- class holoviews.__init__.Dataset(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
Element
Dataset provides a general baseclass for Element types that contain structured data and supports a range of data formats.
The Dataset class supports various methods offering a consistent way of working with the stored data regardless of the storage format used. These operations include indexing, selection and various ways of aggregating or collapsing the data with a supplied function.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdims, kdims, vdimsgroup
= param.String(allow_refs=False, constant=True, default=’Dataset’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1253f7e50>)A string describing the data wrapped by the object.
datatype
= param.List(allow_refs=False, bounds=(0, None), default=[‘dataframe’, ‘dictionary’, ‘grid’, ‘xarray’, ‘multitabular’, ‘spatialpandas’, ‘dask_spatialpandas’, ‘dask’, ‘cuDF’, ‘array’, ‘ibis’], label=’Datatype’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12540f8d0>)A priority list of the data types to be used for storage on the .data attribute. If the input supplied to the element constructor cannot be put into the requested format, the next format listed will be used until a suitable format is found (or the data fails to be understood).
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Dimension(spec, **params)[source]#
Bases:
Parameterized
Dimension objects are used to specify some important general features that may be associated with a collection of values.
For instance, a Dimension may specify that a set of numeric values actually correspond to ‘Height’ (dimension name), in units of meters, with a descriptive label ‘Height of adult males’.
All dimensions object have a name that identifies them and a label containing a suitable description. If the label is not explicitly specified it matches the name.
These two parameters define the core identity of the dimension object and must match if two dimension objects are to be considered equivalent. All other parameters are considered optional metadata and are not used when testing for equality.
Unlike all the other parameters, these core parameters can be used to construct a Dimension object from a tuple. This format is sufficient to define an identical Dimension:
Dimension(‘a’, label=’Dimension A’) == Dimension((‘a’, ‘Dimension A’))
Everything else about a dimension is considered to reflect non-semantic preferences. Examples include the default value (which may be used in a visualization to set an initial slider position), how the value is to rendered as text (which may be used to specify the printed floating point precision) or a suitable range of values to consider for a particular analysis.
Units#
Full unit support with automated conversions are on the HoloViews roadmap. Once rich unit objects are supported, the unit (or more specifically the type of unit) will be part of the core dimension specification used to establish equality.
Until this feature is implemented, there are two auxiliary parameters that hold some partial information about the unit: the name of the unit and whether or not it is cyclic. The name of the unit is used as part of the pretty-printed representation and knowing whether it is cyclic is important for certain operations.
label
= param.String(allow_None=True, allow_refs=False, label=’Label’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125334050>)Unrestricted label used to describe the dimension. A label should succinctly describe the dimension and may contain any characters, including Unicode and LaTeX expression.
cyclic
= param.Boolean(allow_refs=False, default=False, label=’Cyclic’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12535cf10>)Whether the range of this feature is cyclic such that the maximum allowed value (defined by the range parameter) is continuous with the minimum allowed value.
default
= param.Parameter(allow_None=True, allow_refs=False, label=’Default’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125337010>)Default value of the Dimension which may be useful for widget or other situations that require an initial or default value.
nodata
= param.Integer(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Nodata’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12535d810>)Optional missing-data value for integer data. If non-None, data with this value will be replaced with NaN.
range
= param.Tuple(allow_refs=False, default=(None, None), label=’Range’, length=2, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12540d5d0>)Specifies the minimum and maximum allowed values for a Dimension. None is used to represent an unlimited bound.
soft_range
= param.Tuple(allow_refs=False, default=(None, None), label=’Soft range’, length=2, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12535ddd0>)Specifies a minimum and maximum reference value, which may be overridden by the data.
step
= param.Number(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Step’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12535c490>)Optional floating point step specifying how frequently the underlying space should be sampled. May be used to define a discrete sampling over the range.
type
= param.Parameter(allow_None=True, allow_refs=False, label=’Type’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12535dd50>)Optional type associated with the Dimension values. The type may be an inbuilt constructor (such as int, str, float) or a custom class object.
unit
= param.String(allow_None=True, allow_refs=False, label=’Unit’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125337d90>)Optional unit string associated with the Dimension. For instance, the string ‘m’ may be used represent units of meters and ‘s’ to represent units of seconds.
value_format
= param.Callable(allow_None=True, allow_refs=False, label=’Value format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12540cdd0>)Formatting function applied to each value before display.
values
= param.List(allow_refs=False, bounds=(0, None), default=[], label=’Values’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125337010>)Optional specification of the allowed value set for the dimension that may also be used to retain a categorical ordering.
- clone(spec=None, **overrides)[source]#
Clones the Dimension with new parameters
Derive a new Dimension that inherits existing parameters except for the supplied, explicit overrides
- Args:
spec (tuple, optional): Dimension tuple specification **overrides: Dimension parameter overrides
- Returns:
Cloned Dimension object
- property pprint_label#
The pretty-printed label string for the Dimension
- pprint_value(value, print_unit=False)[source]#
Applies the applicable formatter to the value.
- Args:
value: Dimension value to format
- Returns:
Formatted dimension value
- pprint_value_string(value)[source]#
Pretty print the dimension value and unit with title_format
- Args:
value: Dimension value to format
- Returns:
Formatted dimension value string with unit
- property spec#
“Returns the Dimensions tuple specification
- Returns:
tuple: Dimension tuple specification
- class holoviews.__init__.Distribution(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
Selection1DExpr
,StatisticsElement
Distribution elements provides a representation for a one-dimensional distribution which can be visualized as a kernel density estimate. The data should be supplied in a tabular format and will use the first column.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.element.Element2D
: extentsholoviews.core.data.Dataset
: datatypegroup
= param.String(allow_refs=False, constant=True, default=’Distribution’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1253ec410>)A string describing the data wrapped by the object.
kdims
= param.List(allow_refs=False, bounds=(1, 1), default=[Dimension(‘Value’)], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1253ed6d0>)The key dimensions defined as list of dimensions that may be used in indexing (and potential slicing) semantics. The order of the dimensions listed here determines the semantics of each component of a multi-dimensional indexing operation. Aliased with key_dimensions.
vdims
= param.List(allow_refs=False, bounds=(0, 1), default=[Dimension(‘Density’)], label=’Vdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1253ec310>)The value dimensions defined as the list of dimensions used to describe the components of the data. If multiple value dimensions are supplied, a particular value dimension may be indexed by name after the key dimensions. Aliased with value_dimensions.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dim, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Div(data, **params)[source]#
Bases:
Element
The Div element represents a div DOM node in an HTML document defined as a string containing valid HTML.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdims, kdims, vdimsgroup
= param.String(allow_refs=False, constant=True, default=’Div’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125418210>)A string describing the data wrapped by the object.
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords, **kwargs)[source]#
Snap list or dict of coordinates to closest position.
- Args:
coords: List of 1D or 2D coordinates **kwargs: Coordinates specified as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- range(dimension, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reduction)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The element after reductions have been applied.
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=False, **sample_values)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_specs=None, **kwargs)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
- Args:
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.DynamicMap(callback, initial_items=None, streams=None, **params)[source]#
Bases:
HoloMap
A DynamicMap is a type of HoloMap where the elements are dynamically generated by a callable. The callable is invoked with values associated with the key dimensions or with values supplied by stream parameters.
Parameters inherited from:
kdims
= param.List(allow_refs=False, bounds=(0, None), constant=True, default=[], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125462f90>)The key dimensions of a DynamicMap map to the arguments of the callback. This mapping can be by position or by name.
callback
= param.ClassSelector(allow_None=True, allow_refs=False, class_=<class ‘holoviews.core.spaces.Callable’>, constant=True, label=’Callback’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125464650>)The callable used to generate the elements. The arguments to the callable includes any number of declared key dimensions as well as any number of stream parameters defined on the input streams. If the callable is an instance of Callable it will be used directly, otherwise it will be automatically wrapped in one.
streams
= param.List(allow_refs=False, bounds=(0, None), constant=True, default=[], label=’Streams’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125462d90>)List of Stream instances to associate with the DynamicMap. The set of parameter values across these streams will be supplied as keyword arguments to the callback when the events are received, updating the streams. Can also be supplied as a dictionary that maps parameters or panel widgets to callback argument names that will then be automatically converted to the equivalent list format.
cache_size
= param.Integer(allow_refs=False, bounds=(1, None), default=500, inclusive_bounds=(True, True), label=’Cache size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125464690>)The number of entries to cache for fast access. This is an LRU cache where the least recently used item is overwritten once the cache is full.
positional_stream_args
= param.Boolean(allow_refs=False, constant=True, default=False, label=’Positional stream args’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125461e50>)If False, stream parameters are passed to the callback as keyword arguments. If True, stream parameters are passed to callback as positional arguments. Each positional argument is a dict containing the contents of a stream. The positional stream arguments follow the positional arguments for each kdim, and they are ordered to match the order of the DynamicMap’s streams list.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the object
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or sequence of the same length as the existing keys.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int) Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- collapse(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Concatenates and aggregates along supplied dimensions
Useful to collapse stacks of objects into a single object, e.g. to average a stack of Images or Curves.
- Args:
- dimensions: Dimension(s) to collapse
Defaults to all key dimensions
function: Aggregation function to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
**kwargs: Keyword arguments passed to the aggregation function
- Returns:
Returns the collapsed element or HoloMap of collapsed elements
- collate()[source]#
Unpacks DynamicMap into container of DynamicMaps
Collation allows unpacking DynamicMaps which return Layout, NdLayout or GridSpace objects into a single such object containing DynamicMaps. Assumes that the items in the layout or grid that is returned do not change.
- Returns:
Collated container containing DynamicMaps
- property current_key#
Returns the current key value.
- property ddims#
The list of deep dimensions
- decollate()[source]#
Packs DynamicMap of nested DynamicMaps into a single DynamicMap that returns a non-dynamic element
Decollation allows packing a DynamicMap of nested DynamicMaps into a single DynamicMap that returns a simple (non-dynamic) element. All nested streams are lifted to the resulting DynamicMap, and are available in the streams property. The callback property of the resulting DynamicMap is a pure, stateless function of the stream values. To avoid stream parameter name conflicts, the resulting DynamicMap is configured with positional_stream_args=True, and the callback function accepts stream values as positional dict arguments.
- Returns:
DynamicMap that returns a non-dynamic element
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- drop_dimension(dimensions)[source]#
Drops dimension(s) from keys
- Args:
dimensions: Dimension(s) to drop
- Returns:
Clone of object with with dropped dimension(s)
- event(**kwargs)[source]#
Updates attached streams and triggers events
Automatically find streams matching the supplied kwargs to update and trigger events on them.
- Args:
**kwargs: Events to update streams with
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- grid(dimensions=None, **kwargs)[source]#
Groups data by supplied dimension(s) laying the groups along the dimension(s) out in a GridSpace.
Args: dimensions: Dimension/str or list
Dimension or list of dimensions to group by
Returns: grid: GridSpace
GridSpace with supplied dimensions
- property group#
Group inherited from items
- groupby(dimensions=None, container_type=None, group_type=None, **kwargs)[source]#
Groups DynamicMap by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of DynamicMap and adjoined histogram if adjoin=True, otherwise just the histogram
- property info#
Prints information about the Dimensioned object, including the number and type of objects contained within it and information about its dimensions.
- property label#
Label inherited from items
- property last#
Returns the item highest data item along the map dimensions.
- property last_key#
Returns the last key value.
- layout(dimensions=None, **kwargs)[source]#
Groups data by supplied dimension(s) laying the groups along the dimension(s) out in a NdLayout.
Args: dimensions: Dimension/str or list
Dimension or list of dimensions to group by
Returns: layout: NdLayout
NdLayout with supplied dimensions
- map(map_fn, specs=None, clone=True, link_inputs=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- options(*args, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options defined in a flat format to the objects returned by the DynamicMap. If the options are to be set directly on the objects returned by the DynamicMap a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- overlay(dimensions=None, **kwargs)[source]#
Group by supplied dimension(s) and overlay each group
Groups data by supplied dimension(s) overlaying the groups along the dimension(s).
- Args:
dimensions: Dimension(s) of dimensions to group by
- Returns:
NdOverlay object(s) with supplied dimensions
- range(dimension, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reindex(kdims=None, force=False)[source]#
Reorders key dimensions on DynamicMap
Create a new object with a reordered set of key dimensions. Dropping dimensions is not allowed on a DynamicMap.
- Args:
kdims: List of dimensions to reindex the mapping with force: Not applicable to a DynamicMap
- Returns:
Reindexed DynamicMap
- relabel(label=None, group=None, depth=1)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- select(selection_specs=None, **kwargs)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
- Args:
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- property type#
The type of elements stored in the mapping.
- property unbounded#
Returns a list of key dimensions that are unbounded, excluding stream parameters. If any of these key dimensions are unbounded, the DynamicMap as a whole is also unbounded.
- class holoviews.__init__.EdgePaths(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
Path
EdgePaths is a simple Element representing the paths of edges connecting nodes in a graph.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.element.Element2D
: extentsholoviews.element.geom.Geometry
: kdims, vdimsholoviews.element.path.Path
: datatypegroup
= param.String(allow_refs=False, constant=True, default=’EdgePaths’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125252450>)A string describing the data wrapped by the object.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- split(start=None, end=None, datatype=None, **kwargs)[source]#
The split method allows splitting a Path type into a list of subpaths of the same type. A start and/or end may be supplied to select a subset of paths.
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Element(data, kdims=None, vdims=None, **params)[source]#
Bases:
ViewableElement
,Composable
,Overlayable
Element is the atomic datastructure used to wrap some data with an associated visual representation, e.g. an element may represent a set of points, an image or a curve. Elements provide a common API for interacting with data of different types and define how the data map to a set of dimensions and how those map to the visual representation.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdims, kdims, vdimsgroup
= param.String(allow_refs=False, constant=True, default=’Element’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125274110>)A string describing the data wrapped by the object.
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords, **kwargs)[source]#
Snap list or dict of coordinates to closest position.
- Args:
coords: List of 1D or 2D coordinates **kwargs: Coordinates specified as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- range(dimension, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reduction)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The element after reductions have been applied.
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=False, **sample_values)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_specs=None, **kwargs)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
- Args:
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Ellipse(*args, **kwargs)[source]#
Bases:
BaseShape
Draw an axis-aligned ellipse at the specified x,y position with the given orientation.
The simplest (default) Ellipse is a circle, specified using:
Ellipse(x,y, diameter)
A circle is a degenerate ellipse where the width and height are equal. To specify these explicitly, you can use:
Ellipse(x,y, (width, height))
There is also an aspect parameter allowing you to generate an ellipse by specifying a multiplicating factor that will be applied to the height only.
Note that as a subclass of Path, internally an Ellipse is a sequence of (x,y) sample positions. Ellipse could also be implemented as an annotation that uses a dedicated ellipse artist.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.element.Element2D
: extentsholoviews.element.geom.Geometry
: kdims, vdimsholoviews.element.path.Path
: datatypegroup
= param.String(allow_refs=False, constant=True, default=’Ellipse’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1252d1d90>)The assigned group name.
x
= param.Number(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’X’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1252ea510>)The x-position of the ellipse center.
y
= param.Number(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Y’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1252eaad0>)The y-position of the ellipse center.
width
= param.Number(allow_refs=False, default=1, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1252e9d90>)The width of the ellipse.
height
= param.Number(allow_refs=False, default=1, inclusive_bounds=(True, True), label=’Height’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1252ea050>)The height of the ellipse.
orientation
= param.Number(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Orientation’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1252ea290>)Orientation in the Cartesian coordinate system, the counterclockwise angle in radians between the first axis and the horizontal.
aspect
= param.Number(allow_refs=False, default=1.0, inclusive_bounds=(True, True), label=’Aspect’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1252ea7d0>)Optional multiplier applied to the diameter to compute the width in cases where only the diameter value is set.
samples
= param.Number(allow_refs=False, default=100, inclusive_bounds=(True, True), label=’Samples’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1252ea510>)The sample count used to draw the ellipse.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(*args, **overrides)[source]#
Returns a clone of the object with matching parameter values containing the specified args and kwargs.
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- split(start=None, end=None, datatype=None, **kwargs)[source]#
The split method allows splitting a Path type into a list of subpaths of the same type. A start and/or end may be supplied to select a subset of paths.
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Empty(*, cdims, kdims, vdims, group, label, name)[source]#
Bases:
Dimensioned
,Composable
Empty may be used to define an empty placeholder in a Layout. It can be placed in a Layout just like any regular Element and container type via the + operator or by passing it to the Layout constructor as a part of a list.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdims, kdims, vdimsgroup
= param.String(allow_refs=False, default=’Empty’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125558810>)A string describing the data wrapped by the object.
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- property ddims#
The list of deep dimensions
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- range(dimension, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- select(selection_specs=None, **kwargs)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
- Args:
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.ErrorBars(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
Selection1DExpr
,Chart
ErrorBars is a Chart element representing error bars in a 1D coordinate system where the key dimension corresponds to the location along the x-axis and the first value dimension corresponds to the location along the y-axis and one or two extra value dimensions corresponding to the symmetric or asymmetric errors either along x-axis or y-axis. If two value dimensions are given, then the last value dimension will be taken as symmetric errors. If three value dimensions are given then the last two value dimensions will be taken as negative and positive errors. By default the errors are defined along y-axis. A parameter horizontal, when set True, will define the errors along the x-axis.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.element.Element2D
: extentsholoviews.core.data.Dataset
: datatypegroup
= param.String(allow_refs=False, constant=True, default=’ErrorBars’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125596610>)A string describing the quantity measured by the ErrorBars object.
vdims
= param.List(allow_refs=False, bounds=(1, None), constant=True, default=[Dimension(‘y’), Dimension(‘yerror’)], label=’Vdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1255a1750>)The value dimensions of the Chart, usually corresponding to a number of dependent variables.
horizontal
= param.Boolean(allow_refs=False, default=False, label=’Horizontal’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125596590>)Whether the errors are along y-axis (vertical) or x-axis.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
Range of the y-dimension includes the symmetric or asymmetric error.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Graph(data=None, kdims=None, vdims=None, **kwargs)[source]#
-
Graph is high-level Element representing both nodes and edges. A Graph may be defined in an abstract form representing just the abstract edges between nodes and optionally may be made concrete by supplying a Nodes Element defining the concrete positions of each node. If the node positions are supplied the EdgePaths (defining the concrete edges) can be inferred automatically or supplied explicitly.
The constructor accepts regular columnar data defining the edges or a tuple of the abstract edges and nodes, or a tuple of the abstract edges, nodes, and edgepaths.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdims, vdimsholoviews.core.element.Element2D
: extentsholoviews.core.data.Dataset
: datatypegroup
= param.String(allow_refs=False, constant=True, default=’Graph’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125609f90>)A string describing the data wrapped by the object.
kdims
= param.List(allow_refs=False, bounds=(2, 2), default=[Dimension(‘start’), Dimension(‘end’)], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125621810>)The key dimensions defined as list of dimensions that may be used in indexing (and potential slicing) semantics. The order of the dimensions listed here determines the semantics of each component of a multi-dimensional indexing operation. Aliased with key_dimensions.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- property edgepaths#
Returns the fixed EdgePaths or computes direct connections between supplied nodes.
- classmethod from_networkx(G, positions, nodes=None, **kwargs)[source]#
Generate a HoloViews Graph from a networkx.Graph object and networkx layout function or dictionary of node positions. Any keyword arguments will be passed to the layout function. By default it will extract all node and edge attributes from the networkx.Graph but explicit node information may also be supplied. Any non-scalar attributes, such as lists or dictionaries will be ignored.
- Args:
G (networkx.Graph): Graph to convert to Graph element positions (dict or callable): Node positions
Node positions defined as a dictionary mapping from node id to (x, y) tuple or networkx layout function which computes a positions dictionary
kwargs (dict): Keyword arguments for layout function
- Returns:
Graph element
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- property nodes#
Computes the node positions the first time they are requested if no explicit node information was supplied.
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dimension, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, selection_mode='edges', **selection)[source]#
Allows selecting data by the slices, sets and scalar values along a particular dimension. The indices should be supplied as keywords mapping between the selected dimension and value. Additionally selection_specs (taking the form of a list of type.group.label strings, types or functions) may be supplied, which will ensure the selection is only applied if the specs match the selected object.
Selecting by a node dimensions selects all edges and nodes that are connected to the selected nodes. To select only edges between the selected nodes set the selection_mode to ‘nodes’.
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.GridMatrix(initial_items=None, kdims=None, **params)[source]#
Bases:
GridSpace
GridMatrix is container type for heterogeneous Element types laid out in a grid. Unlike a GridSpace the axes of the Grid must not represent an actual coordinate space, but may be used to plot various dimensions against each other. The GridMatrix is usually constructed using the gridmatrix operation, which will generate a GridMatrix plotting each dimension in an Element against each other.
Parameters inherited from:
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the object
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or sequence of the same length as the existing keys.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int) Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- collapse(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Concatenates and aggregates along supplied dimensions
Useful to collapse stacks of objects into a single object, e.g. to average a stack of Images or Curves.
- Args:
- dimensions: Dimension(s) to collapse
Defaults to all key dimensions
function: Aggregation function to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
**kwargs: Keyword arguments passed to the aggregation function
- Returns:
Returns the collapsed element or HoloMap of collapsed elements
- property ddims#
The list of deep dimensions
- decollate()[source]#
Packs GridSpace of DynamicMaps into a single DynamicMap that returns a GridSpace
Decollation allows packing a GridSpace of DynamicMaps into a single DynamicMap that returns a GridSpace of simple (non-dynamic) elements. All nested streams are lifted to the resulting DynamicMap, and are available in the streams property. The callback property of the resulting DynamicMap is a pure, stateless function of the stream values. To avoid stream parameter name conflicts, the resulting DynamicMap is configured with positional_stream_args=True, and the callback function accepts stream values as positional dict arguments.
- Returns:
DynamicMap that returns a GridSpace
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- drop_dimension(dimensions)[source]#
Drops dimension(s) from keys
- Args:
dimensions: Dimension(s) to drop
- Returns:
Clone of object with with dropped dimension(s)
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- property group#
Group inherited from items
- groupby(dimensions, container_type=None, group_type=None, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- property info#
Prints information about the Dimensioned object, including the number and type of objects contained within it and information about its dimensions.
- keys(full_grid=False)[source]#
Returns the keys of the GridSpace
- Args:
full_grid (bool, optional): Return full cross-product of keys
- Returns:
List of keys
- property label#
Label inherited from items
- property last#
The last of a GridSpace is another GridSpace constituted of the last of the individual elements. To access the elements by their X,Y position, either index the position directly or use the items() method.
- property last_key#
Returns the last key value.
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- range(dimension, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reindex(kdims=None, force=False)[source]#
Reindexes object dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.
Reducing the number of key dimensions will discard information from the keys. All data values are accessible in the newly created object as the new labels must be sufficient to address each value uniquely.
- Args:
kdims (optional): New list of key dimensions after reindexing force (bool, optional): Whether to drop non-unique items
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- select(selection_specs=None, **kwargs)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
- Args:
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the 2D shape of the GridSpace as (rows, cols).
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- property type#
The type of elements stored in the mapping.
- class holoviews.__init__.GridSpace(initial_items=None, kdims=None, **params)[source]#
Bases:
Layoutable
,UniformNdMapping
Grids are distinct from Layouts as they ensure all contained elements to be of the same type. Unlike Layouts, which have integer keys, Grids usually have floating point keys, which correspond to a grid sampling in some two-dimensional space. This two-dimensional space may have to arbitrary dimensions, e.g. for 2D parameter spaces.
Parameters inherited from:
kdims
= param.List(allow_refs=False, bounds=(1, 2), default=[Dimension(‘X’), Dimension(‘Y’)], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125726c10>)The key dimensions defined as list of dimensions that may be used in indexing (and potential slicing) semantics. The order of the dimensions listed here determines the semantics of each component of a multi-dimensional indexing operation. Aliased with key_dimensions.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the object
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or sequence of the same length as the existing keys.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int) Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- collapse(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Concatenates and aggregates along supplied dimensions
Useful to collapse stacks of objects into a single object, e.g. to average a stack of Images or Curves.
- Args:
- dimensions: Dimension(s) to collapse
Defaults to all key dimensions
function: Aggregation function to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
**kwargs: Keyword arguments passed to the aggregation function
- Returns:
Returns the collapsed element or HoloMap of collapsed elements
- property ddims#
The list of deep dimensions
- decollate()[source]#
Packs GridSpace of DynamicMaps into a single DynamicMap that returns a GridSpace
Decollation allows packing a GridSpace of DynamicMaps into a single DynamicMap that returns a GridSpace of simple (non-dynamic) elements. All nested streams are lifted to the resulting DynamicMap, and are available in the streams property. The callback property of the resulting DynamicMap is a pure, stateless function of the stream values. To avoid stream parameter name conflicts, the resulting DynamicMap is configured with positional_stream_args=True, and the callback function accepts stream values as positional dict arguments.
- Returns:
DynamicMap that returns a GridSpace
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- drop_dimension(dimensions)[source]#
Drops dimension(s) from keys
- Args:
dimensions: Dimension(s) to drop
- Returns:
Clone of object with with dropped dimension(s)
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- property group#
Group inherited from items
- groupby(dimensions, container_type=None, group_type=None, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- property info#
Prints information about the Dimensioned object, including the number and type of objects contained within it and information about its dimensions.
- keys(full_grid=False)[source]#
Returns the keys of the GridSpace
- Args:
full_grid (bool, optional): Return full cross-product of keys
- Returns:
List of keys
- property label#
Label inherited from items
- property last#
The last of a GridSpace is another GridSpace constituted of the last of the individual elements. To access the elements by their X,Y position, either index the position directly or use the items() method.
- property last_key#
Returns the last key value.
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- range(dimension, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reindex(kdims=None, force=False)[source]#
Reindexes object dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.
Reducing the number of key dimensions will discard information from the keys. All data values are accessible in the newly created object as the new labels must be sufficient to address each value uniquely.
- Args:
kdims (optional): New list of key dimensions after reindexing force (bool, optional): Whether to drop non-unique items
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- select(selection_specs=None, **kwargs)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
- Args:
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the 2D shape of the GridSpace as (rows, cols).
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- property type#
The type of elements stored in the mapping.
- class holoviews.__init__.HLine(y, **params)[source]#
Bases:
Annotation
Horizontal line annotation at the given position.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdims, vdimsholoviews.core.element.Element2D
: extentsgroup
= param.String(allow_refs=False, constant=True, default=’HLine’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1257a67d0>)A string describing the data wrapped by the object.
y
= param.ClassSelector(allow_refs=False, class_=(<class ‘numbers.Number’>, <class ‘numpy.datetime64’>, <class ‘datetime.datetime’>, <class ‘datetime.date’>, <class ‘datetime.time’>, <class ‘pandas._libs.tslibs.timestamps.Timestamp’>, <class ‘pandas.core.dtypes.dtypes.DatetimeTZDtype’>, <class ‘pandas._libs.tslibs.period.Period’>, <class ‘cftime._cftime.datetime’>), default=0, label=’Y’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1257a80d0>)The y-position of the HLine which make be numeric or a timestamp.
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(*args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords, **kwargs)[source]#
Snap list or dict of coordinates to closest position.
- Args:
coords: List of 1D or 2D coordinates **kwargs: Coordinates specified as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- range(dimension, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reduction)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The element after reductions have been applied.
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=False, **sample_values)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_specs=None, **kwargs)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
- Args:
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.HLines(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
VectorizedAnnotation
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdims, vdimsholoviews.core.element.Element2D
: extentsholoviews.core.data.Dataset
: datatypegroup
= param.String(allow_refs=False, constant=True, default=’HLines’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1257f7d50>)A string describing the data wrapped by the object.
kdims
= param.List(allow_refs=False, bounds=(1, 1), default=[Dimension(‘y’)], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1257fa690>)The key dimensions defined as list of dimensions that may be used in indexing (and potential slicing) semantics. The order of the dimensions listed here determines the semantics of each component of a multi-dimensional indexing operation. Aliased with key_dimensions.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.HSV(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
RGB
HSV represents a regularly spaced 2D grid of an underlying continuous space of HSV (hue, saturation and value) color space values. The definition of the grid closely matches the semantics of an Image or RGB element and in the simplest case the grid may be specified as a NxMx3 or NxMx4 array of values along with a bounds, but it may also be defined through explicit and regularly spaced x/y-coordinate arrays. The two most basic supported constructors of an HSV element therefore include:
HSV((X, Y, H, S, V))
where X is a 1D array of shape M, Y is a 1D array of shape N and H/S/V are 2D array of shape NxM, or equivalently:
HSV(Z, bounds=(x0, y0, x1, y1))
where Z is a 3D array of stacked H/S/V arrays with shape NxMx3/4 and the bounds define the (left, bottom, top, right) edges of the four corners of the grid. Other gridded formats which support declaring of explicit x/y-coordinate arrays such as xarray are also supported.
Note that the interpretation of the orientation changes depending on whether bounds or explicit coordinates are used.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.element.Element2D
: extentsholoviews.element.raster.Image
: kdims, datatype, bounds, rtolgroup
= param.String(allow_refs=False, constant=True, default=’HSV’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1259b9210>)A string describing the data wrapped by the object.
vdims
= param.List(allow_refs=False, bounds=(3, 4), default=[Dimension(‘H’), Dimension(‘S’), Dimension(‘V’)], label=’Vdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1259b9810>)The dimension description of the data held in the array. If an alpha channel is supplied, the defined alpha_dimension is automatically appended to this list.
alpha_dimension
= param.ClassSelector(allow_refs=False, class_=<class ‘holoviews.core.dimension.Dimension’>, default=Dimension(‘A’), label=’Alpha dimension’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1259ba450>)The alpha dimension definition to add the value dimensions if an alpha channel is supplied.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Returns a clone of the object with matching parameter values containing the specified args and kwargs.
If shared_data is set to True and no data explicitly supplied, the clone will share data with the original. May also supply a new_type, which will inherit all shared parameters.
- closest(coords=None, **kwargs)[source]#
Given a single coordinate or multiple coordinates as a tuple or list of tuples or keyword arguments matching the dimension closest will find the closest actual x/y coordinates.
- closest_cell_center(x, y)[source]#
Given arbitrary sheet coordinates, return the sheet coordinates of the center of the closest unit.
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- classmethod load_image(filename, height=1, array=False, bounds=None, bare=False, **kwargs)[source]#
Load an image from a file and return an RGB element or array
- Args:
filename: Filename of the image to be loaded height: Determines the bounds of the image where the width
is scaled relative to the aspect ratio of the image.
array: Whether to return an array (rather than RGB default) bounds: Bounds for the returned RGB (overrides height) bare: Whether to hide the axes kwargs: Additional kwargs to the RGB constructor
- Returns:
RGB element or array
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- matrix2sheet(float_row, float_col)[source]#
Convert a floating-point location (float_row,float_col) in matrix coordinates to its corresponding location (x,y) in sheet coordinates.
Valid for scalar or array float_row and float_col.
Inverse of sheet2matrix().
- matrixidx2sheet(row, col)[source]#
Return (x,y) where x and y are the floating point coordinates of the center of the given matrix cell (row,col). If the matrix cell represents a 0.2 by 0.2 region, then the center location returned would be 0.1,0.1.
NOTE: This is NOT the strict mathematical inverse of sheet2matrixidx(), because sheet2matrixidx() discards all but the integer portion of the continuous matrix coordinate.
Valid only for scalar or array row and col.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- property rgb#
Conversion from HSV to RGB.
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_specs=None, **selection)[source]#
Allows selecting data by the slices, sets and scalar values along a particular dimension. The indices should be supplied as keywords mapping between the selected dimension and value. Additionally selection_specs (taking the form of a list of type.group.label strings, types or functions) may be supplied, which will ensure the selection is only applied if the specs match the selected object.
- property shape#
Returns the shape of the data.
- sheet2matrix(x, y)[source]#
Convert a point (x,y) in Sheet coordinates to continuous matrix coordinates.
Returns (float_row,float_col), where float_row corresponds to y, and float_col to x.
Valid for scalar or array x and y.
Note about Bounds For a Sheet with BoundingBox(points=((-0.5,-0.5),(0.5,0.5))) and density=3, x=-0.5 corresponds to float_col=0.0 and x=0.5 corresponds to float_col=3.0. float_col=3.0 is not inside the matrix representing this Sheet, which has the three columns (0,1,2). That is, x=-0.5 is inside the BoundingBox but x=0.5 is outside. Similarly, y=0.5 is inside (at row 0) but y=-0.5 is outside (at row 3) (it’s the other way round for y because the matrix row index increases as y decreases).
- sheet2matrixidx(x, y)[source]#
Convert a point (x,y) in sheet coordinates to the integer row and column index of the matrix cell in which that point falls, given a bounds and density. Returns (row,column).
Note that if coordinates along the right or bottom boundary are passed into this function, the returned matrix coordinate of the boundary will be just outside the matrix, because the right and bottom boundaries are exclusive.
Valid for scalar or array x and y.
- sheetcoordinates_of_matrixidx()[source]#
Return x,y where x is a vector of sheet coordinates representing the x-center of each matrix cell, and y represents the corresponding y-center of the cell.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- property xdensity#
The spacing between elements in an underlying matrix representation, in the x direction.
- property ydensity#
The spacing between elements in an underlying matrix representation, in the y direction.
- class holoviews.__init__.HSpan(y1=None, y2=None, **params)[source]#
Bases:
Annotation
Horizontal span annotation at the given position.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdims, vdimsholoviews.core.element.Element2D
: extentsgroup
= param.String(allow_refs=False, constant=True, default=’HSpan’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125903d90>)A string describing the data wrapped by the object.
y1
= param.ClassSelector(allow_None=True, allow_refs=False, class_=(<class ‘numbers.Number’>, <class ‘numpy.datetime64’>, <class ‘datetime.datetime’>, <class ‘datetime.date’>, <class ‘datetime.time’>, <class ‘pandas._libs.tslibs.timestamps.Timestamp’>, <class ‘pandas.core.dtypes.dtypes.DatetimeTZDtype’>, <class ‘pandas._libs.tslibs.period.Period’>, <class ‘cftime._cftime.datetime’>), default=0, label=’Y1’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125921650>)The start y-position of the VSpan which must be numeric or a timestamp.
y2
= param.ClassSelector(allow_None=True, allow_refs=False, class_=(<class ‘numbers.Number’>, <class ‘numpy.datetime64’>, <class ‘datetime.datetime’>, <class ‘datetime.date’>, <class ‘datetime.time’>, <class ‘pandas._libs.tslibs.timestamps.Timestamp’>, <class ‘pandas.core.dtypes.dtypes.DatetimeTZDtype’>, <class ‘pandas._libs.tslibs.period.Period’>, <class ‘cftime._cftime.datetime’>), default=0, label=’Y2’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125903e10>)The end y-position of the VSpan which must be numeric or a timestamp.
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(*args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords, **kwargs)[source]#
Snap list or dict of coordinates to closest position.
- Args:
coords: List of 1D or 2D coordinates **kwargs: Coordinates specified as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- range(dimension, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reduction)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The element after reductions have been applied.
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=False, **sample_values)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_specs=None, **kwargs)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
- Args:
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.HSpans(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
VectorizedAnnotation
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdims, vdimsholoviews.core.element.Element2D
: extentsholoviews.core.data.Dataset
: datatypegroup
= param.String(allow_refs=False, constant=True, default=’HSpans’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12598c890>)A string describing the data wrapped by the object.
kdims
= param.List(allow_refs=False, bounds=(2, 2), default=[Dimension(‘y0’), Dimension(‘y1’)], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12598ed50>)The key dimensions defined as list of dimensions that may be used in indexing (and potential slicing) semantics. The order of the dimensions listed here determines the semantics of each component of a multi-dimensional indexing operation. Aliased with key_dimensions.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.HeatMap(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
Selection2DExpr
,Dataset
,Element2D
HeatMap represents a 2D grid of categorical coordinates which can be computed from a sparse tabular representation. A HeatMap does not automatically aggregate the supplied values, so if the data contains multiple entries for the same coordinate on the 2D grid it should be aggregated using the aggregate method before display.
The HeatMap constructor will support any tabular or gridded data format with 2 coordinates and at least one value dimension. A simple example:
HeatMap([(x1, y1, z1), (x2, y2, z2), …])
However any tabular and gridded format, including pandas DataFrames, dictionaries of columns, xarray DataArrays and more are supported if the library is importable.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.element.Element2D
: extentsholoviews.core.data.Dataset
: datatypegroup
= param.String(allow_refs=False, constant=True, default=’HeatMap’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125a14810>)A string describing the data wrapped by the object.
kdims
= param.List(allow_refs=False, bounds=(2, 2), constant=True, default=[Dimension(‘x’), Dimension(‘y’)], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125a16210>)The key dimensions defined as list of dimensions that may be used in indexing (and potential slicing) semantics. The order of the dimensions listed here determines the semantics of each component of a multi-dimensional indexing operation. Aliased with key_dimensions.
vdims
= param.List(allow_refs=False, bounds=(0, None), constant=True, default=[Dimension(‘z’)], label=’Vdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125a14b90>)The value dimensions defined as the list of dimensions used to describe the components of the data. If multiple value dimensions are supplied, a particular value dimension may be indexed by name after the key dimensions. Aliased with value_dimensions.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.HexTiles(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
Selection2DExpr
,Dataset
,Element2D
HexTiles is a statistical element with a visual representation that renders a density map of the data values as a hexagonal grid.
Before display the data is aggregated either by counting the values in each hexagonal bin or by computing aggregates.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdims, vdimsholoviews.core.element.Element2D
: extentsholoviews.core.data.Dataset
: datatypegroup
= param.String(allow_refs=False, constant=True, default=’HexTiles’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125a88790>)A string describing the data wrapped by the object.
kdims
= param.List(allow_refs=False, bounds=(2, 2), default=[Dimension(‘x’), Dimension(‘y’)], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125a8a1d0>)The key dimensions defined as list of dimensions that may be used in indexing (and potential slicing) semantics. The order of the dimensions listed here determines the semantics of each component of a multi-dimensional indexing operation. Aliased with key_dimensions.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Histogram(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
Selection1DExpr
,Chart
Histogram is a Chart element representing a number of bins in a 1D coordinate system. The key dimension represents the binned values, which may be declared as bin edges or bin centers, while the value dimensions usually defines a count, frequency or density associated with each bin.
Parameters inherited from:
group
= param.String(allow_refs=False, constant=True, default=’Histogram’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125af8a90>)A string describing the data wrapped by the object.
kdims
= param.List(allow_refs=False, bounds=(1, 1), default=[Dimension(‘x’)], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125b1d8d0>)Dimensions on Element2Ds determine the number of indexable dimensions.
vdims
= param.List(allow_refs=False, bounds=(1, None), default=[Dimension(‘Frequency’)], label=’Vdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125af9110>)The value dimensions of the Chart, usually corresponding to a number of dependent variables.
datatype
= param.List(allow_refs=False, bounds=(0, None), default=[‘grid’], label=’Datatype’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125b1d810>)A priority list of the data types to be used for storage on the .data attribute. If the input supplied to the element constructor cannot be put into the requested format, the next format listed will be used until a suitable format is found (or the data fails to be understood).
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- property edges#
Property to access the Histogram edges provided for backward compatibility
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.HoloMap(initial_items=None, kdims=None, group=None, label=None, **params)[source]#
Bases:
Layoutable
,UniformNdMapping
,Overlayable
A HoloMap is an n-dimensional mapping of viewable elements or overlays. Each item in a HoloMap has an tuple key defining the values along each of the declared key dimensions, defining the discretely sampled space of values.
The visual representation of a HoloMap consists of the viewable objects inside the HoloMap which can be explored by varying one or more widgets mapping onto the key dimensions of the HoloMap.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.ndmapping.MultiDimensionalMapping
: kdims, vdims, sort- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the object
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or sequence of the same length as the existing keys.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int) Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- collapse(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Concatenates and aggregates along supplied dimensions
Useful to collapse stacks of objects into a single object, e.g. to average a stack of Images or Curves.
- Args:
- dimensions: Dimension(s) to collapse
Defaults to all key dimensions
function: Aggregation function to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
**kwargs: Keyword arguments passed to the aggregation function
- Returns:
Returns the collapsed element or HoloMap of collapsed elements
- collate(merge_type=None, drop=None, drop_constant=False)[source]#
Collate allows reordering nested containers
Collation allows collapsing nested mapping types by merging their dimensions. In simple terms in merges nested containers into a single merged type.
In the simple case a HoloMap containing other HoloMaps can easily be joined in this way. However collation is particularly useful when the objects being joined are deeply nested, e.g. you want to join multiple Layouts recorded at different times, collation will return one Layout containing HoloMaps indexed by Time. Changing the merge_type will allow merging the outer Dimension into any other UniformNdMapping type.
- Args:
merge_type: Type of the object to merge with drop: List of dimensions to drop drop_constant: Drop constant dimensions automatically
- Returns:
Collated Layout or HoloMap
- property ddims#
The list of deep dimensions
- decollate()[source]#
Packs HoloMap of DynamicMaps into a single DynamicMap that returns an HoloMap
Decollation allows packing a HoloMap of DynamicMaps into a single DynamicMap that returns an HoloMap of simple (non-dynamic) elements. All nested streams are lifted to the resulting DynamicMap, and are available in the streams property. The callback property of the resulting DynamicMap is a pure, stateless function of the stream values. To avoid stream parameter name conflicts, the resulting DynamicMap is configured with positional_stream_args=True, and the callback function accepts stream values as positional dict arguments.
- Returns:
DynamicMap that returns an HoloMap
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- drop_dimension(dimensions)[source]#
Drops dimension(s) from keys
- Args:
dimensions: Dimension(s) to drop
- Returns:
Clone of object with with dropped dimension(s)
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- grid(dimensions=None, **kwargs)[source]#
Group by supplied dimension(s) and lay out groups in grid
Groups data by supplied dimension(s) laying the groups along the dimension(s) out in a GridSpace.
Args: dimensions: Dimension/str or list
Dimension or list of dimensions to group by
- Returns:
GridSpace with supplied dimensions
- property group#
Group inherited from items
- groupby(dimensions, container_type=None, group_type=None, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, individually=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of HoloMap and histograms or just the histograms
- property info#
Prints information about the Dimensioned object, including the number and type of objects contained within it and information about its dimensions.
- property label#
Label inherited from items
- property last#
Returns the item highest data item along the map dimensions.
- property last_key#
Returns the last key value.
- layout(dimensions=None, **kwargs)[source]#
Group by supplied dimension(s) and lay out groups
Groups data by supplied dimension(s) laying the groups along the dimension(s) out in a NdLayout.
- Args:
dimensions: Dimension(s) to group by
- Returns:
NdLayout with supplied dimensions
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- options(*args, **kwargs)[source]#
Applies simplified option definition returning a new object
Applies options defined in a flat format to the objects returned by the DynamicMap. If the options are to be set directly on the objects in the HoloMap a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- overlay(dimensions=None, **kwargs)[source]#
Group by supplied dimension(s) and overlay each group
Groups data by supplied dimension(s) overlaying the groups along the dimension(s).
- Args:
dimensions: Dimension(s) of dimensions to group by
- Returns:
NdOverlay object(s) with supplied dimensions
- range(dimension, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reindex(kdims=None, force=False)[source]#
Reindexes object dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.
Reducing the number of key dimensions will discard information from the keys. All data values are accessible in the newly created object as the new labels must be sufficient to address each value uniquely.
- Args:
kdims (optional): New list of key dimensions after reindexing force (bool, optional): Whether to drop non-unique items
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=1)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- select(selection_specs=None, **kwargs)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
- Args:
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- property type#
The type of elements stored in the mapping.
- exception holoviews.__init__.HoloviewsDeprecationWarning[source]#
Bases:
DeprecationWarning
A Holoviews-specific
DeprecationWarning
subclass. Used to selectively filter Holoviews deprecations for unconditional display.- add_note()#
Exception.add_note(note) – add a note to the exception
- with_traceback()#
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception holoviews.__init__.HoloviewsUserWarning[source]#
Bases:
UserWarning
A Holoviews-specific
UserWarning
subclass. Used to selectively filter Holoviews warnings for unconditional display.- add_note()#
Exception.add_note(note) – add a note to the exception
- with_traceback()#
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class holoviews.__init__.Image(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
Selection2DExpr
,Dataset
,Raster
,SheetCoordinateSystem
Image represents a regularly sampled 2D grid of an underlying continuous space of intensity values, which will be colormapped on plotting. The grid of intensity values may be specified as a NxM sized array of values along with a bounds, but it may also be defined through explicit and regularly spaced x/y-coordinate arrays of shape M and N respectively. The two most basic supported constructors of an Image therefore include:
Image((X, Y, Z))
where X is a 1D array of shape M, Y is a 1D array of shape N and Z is a 2D array of shape NxM, or equivalently:
Image(Z, bounds=(x0, y0, x1, y1))
where Z is a 2D array of shape NxM defining the intensity values and the bounds define the (left, bottom, top, right) edges of four corners of the grid. Other gridded formats which support declaring of explicit x/y-coordinate arrays such as xarray are also supported.
Note that the interpretation of the orientation of the array changes depending on whether bounds or explicit coordinates are used.
Parameters inherited from:
group
= param.String(allow_refs=False, constant=True, default=’Image’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125c48850>)A string describing the data wrapped by the object.
kdims
= param.List(allow_refs=False, bounds=(2, 2), constant=True, default=[Dimension(‘x’), Dimension(‘y’)], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125c4a010>)The label of the x- and y-dimension of the Raster in the form of a string or dimension object.
vdims
= param.List(allow_refs=False, bounds=(1, None), default=[Dimension(‘z’)], label=’Vdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125c48850>)The dimension description of the data held in the matrix.
datatype
= param.List(allow_refs=False, bounds=(0, None), default=[‘grid’, ‘xarray’, ‘image’, ‘cube’, ‘dataframe’, ‘dictionary’], label=’Datatype’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125c49f50>)A priority list of the data types to be used for storage on the .data attribute. If the input supplied to the element constructor cannot be put into the requested format, the next format listed will be used until a suitable format is found (or the data fails to be understood).
bounds
= param.ClassSelector(allow_refs=False, class_=<class ‘holoviews.core.boundingregion.BoundingRegion’>, default=BoundingBox(radius=0.5), label=’Bounds’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125c48510>)The bounding region in sheet coordinates containing the data.
rtol
= param.Number(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Rtol’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125c4a210>)The tolerance used to enforce regular sampling for regular, gridded data where regular sampling is expected. Expressed as the maximal allowable sampling difference between sample locations.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Returns a clone of the object with matching parameter values containing the specified args and kwargs.
If shared_data is set to True and no data explicitly supplied, the clone will share data with the original. May also supply a new_type, which will inherit all shared parameters.
- closest(coords=None, **kwargs)[source]#
Given a single coordinate or multiple coordinates as a tuple or list of tuples or keyword arguments matching the dimension closest will find the closest actual x/y coordinates.
- closest_cell_center(x, y)[source]#
Given arbitrary sheet coordinates, return the sheet coordinates of the center of the closest unit.
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- matrix2sheet(float_row, float_col)[source]#
Convert a floating-point location (float_row,float_col) in matrix coordinates to its corresponding location (x,y) in sheet coordinates.
Valid for scalar or array float_row and float_col.
Inverse of sheet2matrix().
- matrixidx2sheet(row, col)[source]#
Return (x,y) where x and y are the floating point coordinates of the center of the given matrix cell (row,col). If the matrix cell represents a 0.2 by 0.2 region, then the center location returned would be 0.1,0.1.
NOTE: This is NOT the strict mathematical inverse of sheet2matrixidx(), because sheet2matrixidx() discards all but the integer portion of the continuous matrix coordinate.
Valid only for scalar or array row and col.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_specs=None, **selection)[source]#
Allows selecting data by the slices, sets and scalar values along a particular dimension. The indices should be supplied as keywords mapping between the selected dimension and value. Additionally selection_specs (taking the form of a list of type.group.label strings, types or functions) may be supplied, which will ensure the selection is only applied if the specs match the selected object.
- property shape#
Returns the shape of the data.
- sheet2matrix(x, y)[source]#
Convert a point (x,y) in Sheet coordinates to continuous matrix coordinates.
Returns (float_row,float_col), where float_row corresponds to y, and float_col to x.
Valid for scalar or array x and y.
Note about Bounds For a Sheet with BoundingBox(points=((-0.5,-0.5),(0.5,0.5))) and density=3, x=-0.5 corresponds to float_col=0.0 and x=0.5 corresponds to float_col=3.0. float_col=3.0 is not inside the matrix representing this Sheet, which has the three columns (0,1,2). That is, x=-0.5 is inside the BoundingBox but x=0.5 is outside. Similarly, y=0.5 is inside (at row 0) but y=-0.5 is outside (at row 3) (it’s the other way round for y because the matrix row index increases as y decreases).
- sheet2matrixidx(x, y)[source]#
Convert a point (x,y) in sheet coordinates to the integer row and column index of the matrix cell in which that point falls, given a bounds and density. Returns (row,column).
Note that if coordinates along the right or bottom boundary are passed into this function, the returned matrix coordinate of the boundary will be just outside the matrix, because the right and bottom boundaries are exclusive.
Valid for scalar or array x and y.
- sheetcoordinates_of_matrixidx()[source]#
Return x,y where x is a vector of sheet coordinates representing the x-center of each matrix cell, and y represents the corresponding y-center of the cell.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- property xdensity#
The spacing between elements in an underlying matrix representation, in the x direction.
- property ydensity#
The spacing between elements in an underlying matrix representation, in the y direction.
- class holoviews.__init__.ImageStack(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
Image
ImageStack expands the capabilities of Image to by supporting multiple layers of images.
As there is many ways to represent multiple layers of images, the following options are supported:
A 3D Numpy array with the shape (y, x, level)
A list of 2D Numpy arrays with identical shape (y, x)
- A dictionary where the keys will be set as the vdims and the
values are 2D Numpy arrays with identical shapes (y, x). If the dictionary’s keys matches the kdims of the element, they need to be 1D arrays.
- A tuple containing (x, y, level_0, level_1, …),
where the level is a 2D Numpy array in the shape of (y, x).
An xarray DataArray or Dataset where its coords contain the kdims.
If no kdims are supplied, x and y are used.
If no vdims are supplied, and the naming can be inferred like with a dictionary the levels will be named level_0, level_1, etc.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.element.Element2D
: extentsholoviews.element.raster.Image
: kdims, datatype, bounds, rtolgroup
= param.String(allow_refs=False, constant=True, default=’ImageStack’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125cdb590>)A string describing the data wrapped by the object.
vdims
= param.List(allow_refs=False, bounds=(1, None), default=[Dimension(‘z’)], label=’Vdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125cd0e90>)The dimension description of the data held in the matrix.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Returns a clone of the object with matching parameter values containing the specified args and kwargs.
If shared_data is set to True and no data explicitly supplied, the clone will share data with the original. May also supply a new_type, which will inherit all shared parameters.
- closest(coords=None, **kwargs)[source]#
Given a single coordinate or multiple coordinates as a tuple or list of tuples or keyword arguments matching the dimension closest will find the closest actual x/y coordinates.
- closest_cell_center(x, y)[source]#
Given arbitrary sheet coordinates, return the sheet coordinates of the center of the closest unit.
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- matrix2sheet(float_row, float_col)[source]#
Convert a floating-point location (float_row,float_col) in matrix coordinates to its corresponding location (x,y) in sheet coordinates.
Valid for scalar or array float_row and float_col.
Inverse of sheet2matrix().
- matrixidx2sheet(row, col)[source]#
Return (x,y) where x and y are the floating point coordinates of the center of the given matrix cell (row,col). If the matrix cell represents a 0.2 by 0.2 region, then the center location returned would be 0.1,0.1.
NOTE: This is NOT the strict mathematical inverse of sheet2matrixidx(), because sheet2matrixidx() discards all but the integer portion of the continuous matrix coordinate.
Valid only for scalar or array row and col.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_specs=None, **selection)[source]#
Allows selecting data by the slices, sets and scalar values along a particular dimension. The indices should be supplied as keywords mapping between the selected dimension and value. Additionally selection_specs (taking the form of a list of type.group.label strings, types or functions) may be supplied, which will ensure the selection is only applied if the specs match the selected object.
- property shape#
Returns the shape of the data.
- sheet2matrix(x, y)[source]#
Convert a point (x,y) in Sheet coordinates to continuous matrix coordinates.
Returns (float_row,float_col), where float_row corresponds to y, and float_col to x.
Valid for scalar or array x and y.
Note about Bounds For a Sheet with BoundingBox(points=((-0.5,-0.5),(0.5,0.5))) and density=3, x=-0.5 corresponds to float_col=0.0 and x=0.5 corresponds to float_col=3.0. float_col=3.0 is not inside the matrix representing this Sheet, which has the three columns (0,1,2). That is, x=-0.5 is inside the BoundingBox but x=0.5 is outside. Similarly, y=0.5 is inside (at row 0) but y=-0.5 is outside (at row 3) (it’s the other way round for y because the matrix row index increases as y decreases).
- sheet2matrixidx(x, y)[source]#
Convert a point (x,y) in sheet coordinates to the integer row and column index of the matrix cell in which that point falls, given a bounds and density. Returns (row,column).
Note that if coordinates along the right or bottom boundary are passed into this function, the returned matrix coordinate of the boundary will be just outside the matrix, because the right and bottom boundaries are exclusive.
Valid for scalar or array x and y.
- sheetcoordinates_of_matrixidx()[source]#
Return x,y where x is a vector of sheet coordinates representing the x-center of each matrix cell, and y represents the corresponding y-center of the cell.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- property xdensity#
The spacing between elements in an underlying matrix representation, in the x direction.
- property ydensity#
The spacing between elements in an underlying matrix representation, in the y direction.
- class holoviews.__init__.ItemTable(data, **params)[source]#
Bases:
Element
A tabular element type to allow convenient visualization of either a standard Python dictionary or a list of tuples (i.e. input suitable for an dict constructor). Tables store heterogeneous data with different labels.
Dimension objects are also accepted as keys, allowing dimensional information (e.g. type and units) to be associated per heading.
Parameters inherited from:
group
= param.String(allow_refs=False, constant=True, default=’ItemTable’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125d75a10>)A string describing the data wrapped by the object.
kdims
= param.List(allow_refs=False, bounds=(0, 0), default=[], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125d76590>)ItemTables hold an index Dimension for each value they contain, i.e. they are equivalent to the keys.
vdims
= param.List(allow_refs=False, bounds=(0, None), default=[Dimension(‘Default’)], label=’Vdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125d75a10>)ItemTables should have only index Dimensions.
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- cell_type(row, col)[source]#
Returns the cell type given a row and column index. The common basic cell types are ‘data’ and ‘heading’.
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords, **kwargs)[source]#
Snap list or dict of coordinates to closest position.
- Args:
coords: List of 1D or 2D coordinates **kwargs: Coordinates specified as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- hist(*args, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- range(dimension, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, **reduce_map)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The element after reductions have been applied.
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_specs=None, **kwargs)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
- Args:
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Labels(data=None, kdims=None, vdims=None, **kwargs)[source]#
-
Labels represents a collection of text labels associated with 2D coordinates. Unlike the Text annotation, Labels is a Dataset type which allows drawing vectorized labels from tabular or gridded data.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.element.Element2D
: extentsholoviews.core.data.Dataset
: datatypegroup
= param.String(allow_refs=False, constant=True, default=’Labels’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125dc49d0>)A string describing the data wrapped by the object.
kdims
= param.List(allow_refs=False, bounds=(2, 2), constant=True, default=[Dimension(‘x’), Dimension(‘y’)], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125dd4450>)The label of the x- and y-dimension of the Labels element in form of a string or dimension object.
vdims
= param.List(allow_refs=False, bounds=(1, None), default=[Dimension(‘Label’)], label=’Vdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125dc4fd0>)Defines the value dimension corresponding to the label text.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Layout(items=None, identifier=None, parent=None, **kwargs)[source]#
Bases:
Layoutable
,ViewableTree
A Layout is an ViewableTree with ViewableElement objects as leaf values. Unlike ViewableTree, a Layout supports a rich display, displaying leaf items in a grid style layout. In addition to the usual ViewableTree indexing, Layout supports indexing of items by their row and column index in the layout.
The maximum number of columns in such a layout may be controlled with the cols method.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdims, kdims, vdimsgroup
= param.String(allow_refs=False, constant=True, default=’Layout’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125e55fd0>)A string describing the data wrapped by the object.
- cols(ncols)[source]#
Sets the maximum number of columns in the NdLayout.
Any items beyond the set number of cols will flow onto a new row. The number of columns control the indexing and display semantics of the NdLayout.
- Args:
ncols (int): Number of columns to set on the NdLayout
- property ddims#
The list of deep dimensions
- decollate()[source]#
Packs Layout of DynamicMaps into a single DynamicMap that returns a Layout
Decollation allows packing a Layout of DynamicMaps into a single DynamicMap that returns a Layout of simple (non-dynamic) elements. All nested streams are lifted to the resulting DynamicMap, and are available in the streams property. The callback property of the resulting DynamicMap is a pure, stateless function of the stream values. To avoid stream parameter name conflicts, the resulting DynamicMap is configured with positional_stream_args=True, and the callback function accepts stream values as positional dict arguments.
- Returns:
DynamicMap that returns a Layout
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
Concatenates values on all nodes with requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- property fixed#
If fixed, no new paths can be created via attribute access
- get(identifier, default=None)[source]#
Get a node of the AttrTree using its path string.
- Args:
identifier: Path string of the node to return default: Value to return if no node is found
- Returns:
The indexed node of the AttrTree
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- property path#
Returns the path up to the root for the current node.
- pop(identifier, default=None)[source]#
Pop a node of the AttrTree using its path string.
- Args:
identifier: Path string of the node to return default: Value to return if no node is found
- Returns:
The node that was removed from the AttrTree
- range(dimension, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- relabel(label=None, group=None, depth=1)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- select(selection_specs=None, **kwargs)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
- Args:
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- set_path(path, val)[source]#
Set the given value at the supplied path where path is either a tuple of strings or a string in A.B.C format.
- property shape#
Tuple indicating the number of rows and columns in the Layout.
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- property uniform#
Whether items in tree have uniform dimensions
- class holoviews.__init__.NdLayout(initial_items=None, kdims=None, **params)[source]#
Bases:
Layoutable
,UniformNdMapping
NdLayout is a UniformNdMapping providing an n-dimensional data structure to display the contained Elements and containers in a layout. Using the cols method the NdLayout can be rearranged with the desired number of columns.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.ndmapping.MultiDimensionalMapping
: kdims, vdims, sort- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the object
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or sequence of the same length as the existing keys.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int) Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- collapse(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Concatenates and aggregates along supplied dimensions
Useful to collapse stacks of objects into a single object, e.g. to average a stack of Images or Curves.
- Args:
- dimensions: Dimension(s) to collapse
Defaults to all key dimensions
function: Aggregation function to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
**kwargs: Keyword arguments passed to the aggregation function
- Returns:
Returns the collapsed element or HoloMap of collapsed elements
- cols(ncols)[source]#
Sets the maximum number of columns in the NdLayout.
Any items beyond the set number of cols will flow onto a new row. The number of columns control the indexing and display semantics of the NdLayout.
- Args:
ncols (int): Number of columns to set on the NdLayout
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- drop_dimension(dimensions)[source]#
Drops dimension(s) from keys
- Args:
dimensions: Dimension(s) to drop
- Returns:
Clone of object with with dropped dimension(s)
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- grid_items()[source]#
Compute a dict of {(row,column): (key, value)} elements from the current set of items and specified number of columns.
- property group#
Group inherited from items
- groupby(dimensions, container_type=None, group_type=None, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- property info#
Prints information about the Dimensioned object, including the number and type of objects contained within it and information about its dimensions.
- property label#
Label inherited from items
- property last#
Returns another NdLayout constituted of the last views of the individual elements (if they are maps).
- property last_key#
Returns the last key value.
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- range(dimension, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reindex(kdims=None, force=False)[source]#
Reindexes object dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.
Reducing the number of key dimensions will discard information from the keys. All data values are accessible in the newly created object as the new labels must be sufficient to address each value uniquely.
- Args:
kdims (optional): New list of key dimensions after reindexing force (bool, optional): Whether to drop non-unique items
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- select(selection_specs=None, **kwargs)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
- Args:
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Tuple indicating the number of rows and columns in the NdLayout.
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- property type#
The type of elements stored in the mapping.
- class holoviews.__init__.NdMapping(initial_items=None, kdims=None, **params)[source]#
Bases:
MultiDimensionalMapping
NdMapping supports the same indexing semantics as MultiDimensionalMapping but also supports slicing semantics.
Slicing semantics on an NdMapping is dependent on the ordering semantics of the keys. As MultiDimensionalMapping sort the keys, a slice on an NdMapping is effectively a way of filtering out the keys that are outside the slice range.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.ndmapping.MultiDimensionalMapping
: kdims, vdims, sortgroup
= param.String(allow_refs=False, constant=True, default=’NdMapping’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125ebdd50>)A string describing the data wrapped by the object.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the object
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or sequence of the same length as the existing keys.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int) Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- clone(data=None, shared_data=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- property ddims#
The list of deep dimensions
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- drop_dimension(dimensions)[source]#
Drops dimension(s) from keys
- Args:
dimensions: Dimension(s) to drop
- Returns:
Clone of object with with dropped dimension(s)
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions, container_type=None, group_type=None, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- property info#
Prints information about the Dimensioned object, including the number and type of objects contained within it and information about its dimensions.
- property last#
Returns the item highest data item along the map dimensions.
- property last_key#
Returns the last key value.
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- range(dimension, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reindex(kdims=None, force=False)[source]#
Reindexes object dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.
Reducing the number of key dimensions will discard information from the keys. All data values are accessible in the newly created object as the new labels must be sufficient to address each value uniquely.
- Args:
kdims (optional): New list of key dimensions after reindexing force (bool, optional): Whether to drop non-unique items
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- select(selection_specs=None, **kwargs)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
- Args:
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.NdOverlay(overlays=None, kdims=None, **params)[source]#
Bases:
Overlayable
,UniformNdMapping
,CompositeOverlay
An NdOverlay allows a group of NdOverlay to be overlaid together. NdOverlay can be indexed out of an overlay and an overlay is an iterable that iterates over the contained layers.
Parameters inherited from:
kdims
= param.List(allow_refs=False, bounds=(0, None), constant=True, default=[Dimension(‘Element’)], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125f9fb90>)List of dimensions the NdOverlay can be indexed by.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the object
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or sequence of the same length as the existing keys.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int) Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- collapse(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Concatenates and aggregates along supplied dimensions
Useful to collapse stacks of objects into a single object, e.g. to average a stack of Images or Curves.
- Args:
- dimensions: Dimension(s) to collapse
Defaults to all key dimensions
function: Aggregation function to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
**kwargs: Keyword arguments passed to the aggregation function
- Returns:
Returns the collapsed element or HoloMap of collapsed elements
- property ddims#
The list of deep dimensions
- decollate()[source]#
Packs NdOverlay of DynamicMaps into a single DynamicMap that returns an NdOverlay
Decollation allows packing a NdOverlay of DynamicMaps into a single DynamicMap that returns an NdOverlay of simple (non-dynamic) elements. All nested streams are lifted to the resulting DynamicMap, and are available in the streams property. The callback property of the resulting DynamicMap is a pure, stateless function of the stream values. To avoid stream parameter name conflicts, the resulting DynamicMap is configured with positional_stream_args=True, and the callback function accepts stream values as positional dict arguments.
- Returns:
DynamicMap that returns an NdOverlay
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- drop_dimension(dimensions)[source]#
Drops dimension(s) from keys
- Args:
dimensions: Dimension(s) to drop
- Returns:
Clone of object with with dropped dimension(s)
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- property group#
Group inherited from items
- groupby(dimensions, container_type=None, group_type=None, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, index=None, show_legend=False, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
- dimension: Dimension(s) to compute histogram on,
Falls back the plot dimensions by default.
num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram index (int, optional): Index of layer to apply hist to show_legend (bool, optional): Show legend in histogram
(don’t show legend by default).
- Returns:
AdjointLayout of element and histogram or just the histogram
- property info#
Prints information about the Dimensioned object, including the number and type of objects contained within it and information about its dimensions.
- property label#
Label inherited from items
- property last#
Returns the item highest data item along the map dimensions.
- property last_key#
Returns the last key value.
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- range(dimension, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reindex(kdims=None, force=False)[source]#
Reindexes object dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.
Reducing the number of key dimensions will discard information from the keys. All data values are accessible in the newly created object as the new labels must be sufficient to address each value uniquely.
- Args:
kdims (optional): New list of key dimensions after reindexing force (bool, optional): Whether to drop non-unique items
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- select(selection_specs=None, **kwargs)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
- Args:
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- property type#
The type of elements stored in the mapping.
- class holoviews.__init__.Nodes(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
Points
Nodes is a simple Element representing Graph nodes as a set of Points. Unlike regular Points, Nodes must define a third key dimension corresponding to the node index.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.element.Element2D
: extentsholoviews.core.data.Dataset
: datatypegroup
= param.String(allow_refs=False, constant=True, default=’Nodes’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12611b4d0>)A string describing the data wrapped by the object.
kdims
= param.List(allow_refs=False, bounds=(3, 3), default=[Dimension(‘x’), Dimension(‘y’), Dimension(‘index’)], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126124dd0>)The key dimensions of a geometry represent the x- and y- coordinates in a 2D space.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Operation(*, dynamic, group, input_ranges, link_inputs, streams, name)[source]#
Bases:
ParameterizedFunction
An Operation process an Element or HoloMap at the level of individual elements or overlays. If a holomap is passed in as input, a processed holomap is returned as output where the individual elements have been transformed accordingly. An Operation may turn overlays in new elements or vice versa.
An Operation can be set to be dynamic, which will return a DynamicMap with a callback that will apply the operation dynamically. An Operation may also supply a list of Stream classes on a streams parameter, which can allow dynamic control over the parameters on the operation.
group
= param.String(allow_refs=False, default=’Operation’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1261b4850>)The group string used to identify the output of the Operation. By default this should match the operation name.
dynamic
= param.ObjectSelector(allow_refs=False, default=’default’, label=’Dynamic’, names={}, nested_refs=False, objects=[‘default’, True, False], rx=<param.reactive.reactive_ops object at 0x1261b6c10>)Whether the operation should be applied dynamically when a specific frame is requested, specified as a Boolean. If set to ‘default’ the mode will be determined based on the input type, i.e. if the data is a DynamicMap it will stay dynamic.
input_ranges
= param.ClassSelector(allow_None=True, allow_refs=False, class_=(<class ‘dict’>, <class ‘tuple’>), default={}, label=’Input ranges’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x125c408d0>)Ranges to be used for input normalization (if applicable) in a format appropriate for the Normalization.ranges parameter. By default, no normalization is applied. If key-wise normalization is required, a 2-tuple may be supplied where the first component is a Normalization.ranges list and the second component is Normalization.keys.
link_inputs
= param.Boolean(allow_refs=False, default=False, label=’Link inputs’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1261b6d90>)If the operation is dynamic, whether or not linked streams should be transferred from the operation inputs for backends that support linked streams. For example if an operation 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.
streams
= param.ClassSelector(allow_refs=False, class_=(<class ‘dict’>, <class ‘list’>), default=[], label=’Streams’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1261b4b10>)List of streams that are applied if dynamic=True, allowing for dynamic interaction with the plot.
- classmethod get_overlay_bounds(overlay)[source]#
Returns the extents if all the elements of an overlay agree on a consistent extents, otherwise raises an exception.
- classmethod get_overlay_label(overlay, default_label='')[source]#
Returns a label if all the elements of an overlay agree on a consistent label, otherwise returns the default label.
- classmethod instance(**params)[source]#
Return an instance of this class, copying parameters from any existing instance provided.
- class holoviews.__init__.Options(key=None, allowed_keywords=None, merge_keywords=True, max_cycles=None, **kwargs)[source]#
Bases:
object
An Options object holds a collection of keyword options. In addition, Options support (optional) keyword validation as well as infinite indexing over the set of supplied cyclic values.
Options support inheritance of setting values via the __call__ method. By calling an Options object with additional keywords, you can create a new Options object inheriting the parent options.
- property cyclic#
Returns True if the options cycle, otherwise False
- filtered(allowed)[source]#
Return a new Options object that is filtered by the specified list of keys. Mutating self.kwargs to filter is unsafe due to the option expansion that occurs on initialization.
- keywords_target(target)[source]#
Helper method to easily set the target on the allowed_keywords Keywords.
- max_cycles(num)[source]#
Truncates all contained Palette objects to a maximum number of samples and returns a new Options object containing the truncated or resampled Palettes.
- property options#
Access of the options keywords when no cycles are defined.
- class holoviews.__init__.Overlay(items=None, group=None, label=None, **params)[source]#
Bases:
ViewableTree
,CompositeOverlay
,Layoutable
,Overlayable
An Overlay consists of multiple Elements (potentially of heterogeneous type) presented one on top each other with a particular z-ordering.
Overlays along with elements constitute the only valid leaf types of a Layout and in fact extend the Layout structure. Overlays are constructed using the * operator (building an identical structure to the + operator).
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdims, kdims, vdims- clone(data=None, shared_data=True, new_type=None, link=True, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- collate()[source]#
Collates any objects in the Overlay resolving any issues the recommended nesting structure.
- property ddims#
The list of deep dimensions
- decollate()[source]#
Packs Overlay of DynamicMaps into a single DynamicMap that returns an Overlay
Decollation allows packing an Overlay of DynamicMaps into a single DynamicMap that returns an Overlay of simple (non-dynamic) elements. All nested streams are lifted to the resulting DynamicMap, and are available in the streams property. The callback property of the resulting DynamicMap is a pure, stateless function of the stream values. To avoid stream parameter name conflicts, the resulting DynamicMap is configured with positional_stream_args=True, and the callback function accepts stream values as positional dict arguments.
- Returns:
DynamicMap that returns an Overlay
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
Concatenates values on all nodes with requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- property fixed#
If fixed, no new paths can be created via attribute access
- get(identifier, default=None)[source]#
Get a layer in the Overlay.
Get a particular layer in the Overlay using its path string or an integer index.
- Args:
identifier: Index or path string of the item to return default: Value to return if no item is found
- Returns:
The indexed layer of the Overlay
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- property group#
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, index=None, show_legend=False, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
- dimension: Dimension(s) to compute histogram on,
Falls back the plot dimensions by default.
num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram index (int, optional): Index of layer to apply hist to show_legend (bool, optional): Show legend in histogram
(don’t show legend by default).
- Returns:
AdjointLayout of element and histogram or just the histogram
- property label#
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- property path#
Returns the path up to the root for the current node.
- pop(identifier, default=None)[source]#
Pop a node of the AttrTree using its path string.
- Args:
identifier: Path string of the node to return default: Value to return if no node is found
- Returns:
The node that was removed from the AttrTree
- range(dimension, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- select(selection_specs=None, **kwargs)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
- Args:
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- set_path(path, val)[source]#
Set the given value at the supplied path where path is either a tuple of strings or a string in A.B.C format.
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- property uniform#
Whether items in tree have uniform dimensions
- class holoviews.__init__.Palette(key, **params)[source]#
Bases:
Cycle
Palettes allow easy specifying a discrete sampling of an existing colormap. Palettes may be supplied a key to look up a function function in the colormap class attribute. The function should accept a float scalar in the specified range and return a RGB(A) tuple. The number of samples may also be specified as a parameter.
The range and samples may conveniently be overridden with the __getitem__ method.
Parameters inherited from:
holoviews.core.options.Cycle
: valueskey
= param.String(allow_refs=False, default=’grayscale’, label=’Key’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1262ba1d0>)Palettes look up the Palette values based on some key.
range
= param.NumericTuple(allow_refs=False, default=(0, 1), label=’Range’, length=2, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1262bb910>)The range from which the Palette values are sampled.
samples
= param.Integer(allow_refs=False, default=32, inclusive_bounds=(True, True), label=’Samples’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1262bbd10>)The number of samples in the given range to supply to the sample_fn.
sample_fn
= param.Callable(allow_refs=False, default=<function linspace at 0x101bb3fb0>, label=’Sample fn’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1261d5c90>)The function to generate the samples, by default linear.
reverse
= param.Boolean(allow_refs=False, default=False, label=’Reverse’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1262b9e50>)Whether to reverse the palette.
- sample_fn(stop, num=50, endpoint=True, retstep=False, dtype=None, axis=0, *, device=None)[source]#
Return evenly spaced numbers over a specified interval.
Returns num evenly spaced samples, calculated over the interval [start, stop].
The endpoint of the interval can optionally be excluded.
Changed in version 1.16.0: Non-scalar start and stop are now supported.
Changed in version 1.20.0: Values are rounded towards
-inf
instead of0
when an integerdtype
is specified. The old behavior can still be obtained withnp.linspace(start, stop, num).astype(int)
Parameters#
- startarray_like
The starting value of the sequence.
- stoparray_like
The end value of the sequence, unless endpoint is set to False. In that case, the sequence consists of all but the last of
num + 1
evenly spaced samples, so that stop is excluded. Note that the step size changes when endpoint is False.- numint, optional
Number of samples to generate. Default is 50. Must be non-negative.
- endpointbool, optional
If True, stop is the last sample. Otherwise, it is not included. Default is True.
- retstepbool, optional
If True, return (samples, step), where step is the spacing between samples.
- dtypedtype, optional
The type of the output array. If dtype is not given, the data type is inferred from start and stop. The inferred dtype will never be an integer; float is chosen even if the arguments would produce an array of integers.
Added in version 1.9.0.
- axisint, optional
The axis in the result to store the samples. Relevant only if start or stop are array-like. By default (0), the samples will be along a new axis inserted at the beginning. Use -1 to get an axis at the end.
Added in version 1.16.0.
- devicestr, optional
The device on which to place the created array. Default: None. For Array-API interoperability only, so must be
"cpu"
if passed.Added in version 2.0.0.
Returns#
- samplesndarray
There are num equally spaced samples in the closed interval
[start, stop]
or the half-open interval[start, stop)
(depending on whether endpoint is True or False).- stepfloat, optional
Only returned if retstep is True
Size of spacing between samples.
See Also#
- arangeSimilar to linspace, but uses a step size (instead of the
number of samples).
- geomspaceSimilar to linspace, but with numbers spaced evenly on a log
scale (a geometric progression).
- logspaceSimilar to geomspace, but with the end points specified as
logarithms.
how-to-partition
Examples#
>>> np.linspace(2.0, 3.0, num=5) array([2. , 2.25, 2.5 , 2.75, 3. ]) >>> np.linspace(2.0, 3.0, num=5, endpoint=False) array([2. , 2.2, 2.4, 2.6, 2.8]) >>> np.linspace(2.0, 3.0, num=5, retstep=True) (array([2. , 2.25, 2.5 , 2.75, 3. ]), 0.25)
Graphical illustration:
>>> import matplotlib.pyplot as plt >>> N = 8 >>> y = np.zeros(N) >>> x1 = np.linspace(0, 10, N, endpoint=True) >>> x2 = np.linspace(0, 10, N, endpoint=False) >>> plt.plot(x1, y, 'o') [<matplotlib.lines.Line2D object at 0x...>] >>> plt.plot(x2, y + 0.5, 'o') [<matplotlib.lines.Line2D object at 0x...>] >>> plt.ylim([-0.5, 1]) (-0.5, 1) >>> plt.show()
- class holoviews.__init__.Path(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
SelectionPolyExpr
,Geometry
The Path element represents one or more of path geometries with associated values. Each path geometry may be split into sub-geometries on NaN-values and may be associated with scalar values or array values varying along its length. In analogy to GEOS geometry types a Path is a collection of LineString and MultiLineString geometries with associated values.
Like all other elements a Path may be defined through an extensible list of interfaces. Natively, HoloViews provides the MultiInterface which allows representing paths as lists of regular columnar data objects including arrays, dataframes and dictionaries of column arrays and scalars.
The canonical representation is a list of dictionaries storing the x- and y-coordinates along with any other values:
[{‘x’: 1d-array, ‘y’: 1d-array, ‘value’: scalar, ‘continuous’: 1d-array}, …]
Alternatively Path also supports a single columnar data-structure to specify an individual path:
{‘x’: 1d-array, ‘y’: 1d-array, ‘value’: scalar, ‘continuous’: 1d-array}
Both scalar values and values continuously varying along the geometries coordinates a Path may be used vary visual properties of the paths such as the color. Since not all formats allow storing scalar values as actual scalars, arrays that are the same length as the coordinates but have only one unique value are also considered scalar.
The easiest way of accessing the individual geometries is using the Path.split method, which returns each path geometry as a separate entity, while the other methods assume a flattened representation where all paths are separated by NaN values.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.element.Element2D
: extentsholoviews.element.geom.Geometry
: kdims, vdimsgroup
= param.String(allow_refs=False, constant=True, default=’Path’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1262cdc10>)A string describing the data wrapped by the object.
datatype
= param.List(allow_refs=False, bounds=(0, None), default=[‘multitabular’, ‘spatialpandas’, ‘dask_spatialpandas’], label=’Datatype’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1262dced0>)A priority list of the data types to be used for storage on the .data attribute. If the input supplied to the element constructor cannot be put into the requested format, the next format listed will be used until a suitable format is found (or the data fails to be understood).
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- split(start=None, end=None, datatype=None, **kwargs)[source]#
The split method allows splitting a Path type into a list of subpaths of the same type. A start and/or end may be supplied to select a subset of paths.
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Path3D(data=None, kdims=None, vdims=None, **kwargs)[source]#
-
Path3D is a 3D element representing a line through 3D space. The key dimensions represent the position of each coordinate along the x-, y- and z-axis while the value dimensions can optionally supply additional information.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.element.path.Path
: datatypeholoviews.core.element.Element3D
: extentsgroup
= param.String(allow_refs=False, constant=True, default=’Path3D’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126368790>)A string describing the data wrapped by the object.
kdims
= param.List(allow_refs=False, bounds=(3, 3), default=[Dimension(‘x’), Dimension(‘y’), Dimension(‘z’)], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12636a6d0>)The key dimensions of a geometry represent the x- and y- coordinates in a 2D space.
vdims
= param.List(allow_refs=False, bounds=(0, None), default=[], label=’Vdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126368790>)Path3D can have optional value dimensions.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- split(start=None, end=None, datatype=None, **kwargs)[source]#
The split method allows splitting a Path type into a list of subpaths of the same type. A start and/or end may be supplied to select a subset of paths.
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Points(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
Selection2DExpr
,Geometry
Points represents a set of coordinates in 2D space, which may optionally be associated with any number of value dimensions.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.element.Element2D
: extentsholoviews.core.data.Dataset
: datatypeholoviews.element.geom.Geometry
: kdims, vdimsgroup
= param.String(allow_refs=False, constant=True, default=’Points’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1263ec110>)A string describing the data wrapped by the object.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Polygons(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
Contours
The Polygons element represents one or more polygon geometries with associated scalar values. Each polygon geometry may be split into sub-geometries on NaN-values and may be associated with scalar values. In analogy to GEOS geometry types a Polygons element is a collection of Polygon and MultiPolygon geometries. Polygon geometries are defined as a set of coordinates describing the exterior bounding ring and any number of interior holes.
Like all other elements a Polygons element may be defined through an extensible list of interfaces. Natively HoloViews provides the MultiInterface which allows representing paths as lists of regular columnar data objects including arrays, dataframes and dictionaries of column arrays and scalars.
The canonical representation is a list of dictionaries storing the x- and y-coordinates, a list-of-lists of arrays representing the holes, along with any other values:
[{‘x’: 1d-array, ‘y’: 1d-array, ‘holes’: list-of-lists-of-arrays, ‘value’: scalar}, …]
Alternatively Polygons also supports a single columnar data-structure to specify an individual polygon:
{‘x’: 1d-array, ‘y’: 1d-array, ‘holes’: list-of-lists-of-arrays, ‘value’: scalar}
The list-of-lists format of the holes corresponds to the potential for each coordinate array to be split into a multi-geometry through NaN-separators. Each sub-geometry separated by the NaNs therefore has an unambiguous mapping to a list of holes. If a (multi-)polygon has no holes, the ‘holes’ key may be omitted.
Any value dimensions stored on a Polygons geometry must be scalar, just like the Contours element. Since not all formats allow storing scalar values as actual scalars arrays which are the same length as the coordinates but have only one unique value are also considered scalar.
The easiest way of accessing the individual geometries is using the Polygons.split method, which returns each path geometry as a separate entity, while the other methods assume a flattened representation where all paths are separated by NaN values.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.element.Element2D
: extentsholoviews.element.geom.Geometry
: kdimsholoviews.element.path.Path
: datatypegroup
= param.String(allow_refs=False, constant=True, default=’Polygons’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126474e90>)A string describing the data wrapped by the object.
vdims
= param.List(allow_refs=False, bounds=(0, None), default=[], label=’Vdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126476690>)Polygons optionally accept a value dimension, corresponding to the supplied value.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- property has_holes#
Detects whether any polygon in the Polygons element defines holes. Useful to avoid expanding Polygons unless necessary.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- holes()[source]#
Returns a list-of-lists-of-lists of hole arrays. The three levels of nesting reflects the structure of the polygons:
The first level of nesting corresponds to the list of geometries
The second level corresponds to each Polygon in a MultiPolygon
The third level of nesting allows for multiple holes per Polygon
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- split(start=None, end=None, datatype=None, **kwargs)[source]#
The split method allows splitting a Path type into a list of subpaths of the same type. A start and/or end may be supplied to select a subset of paths.
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.QuadMesh(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
Selection2DExpr
,Dataset
,Element2D
A QuadMesh represents 2D rectangular grid expressed as x- and y-coordinates defined as 1D or 2D arrays. Unlike the Image type a QuadMesh may be regularly or irregularly spaced and contain either bin edges or bin centers. If bin edges are supplied the shape of the x/y-coordinate arrays should be one greater than the shape of the value array.
The default interface expects data to be specified in the form:
QuadMesh((X, Y, Z))
where X and Y may be 1D or 2D arrays of the shape N(+1) and M(+1) respectively or N(+1)xM(+1) and the Z value array should be of shape NxM. Other gridded formats such as xarray are also supported if installed.
The grid orientation follows the standard matrix convention: An array Z with shape (nrows, ncolumns) is plotted with the column number as X and the row number as Y.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.element.Element2D
: extentsholoviews.core.data.Dataset
: datatypegroup
= param.String(allow_refs=False, constant=True, default=’QuadMesh’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1264ff910>)A string describing the data wrapped by the object.
kdims
= param.List(allow_refs=False, bounds=(2, 2), constant=True, default=[Dimension(‘x’), Dimension(‘y’)], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126505590>)The key dimensions defined as list of dimensions that may be used in indexing (and potential slicing) semantics. The order of the dimensions listed here determines the semantics of each component of a multi-dimensional indexing operation. Aliased with key_dimensions.
vdims
= param.List(allow_refs=False, bounds=(1, None), default=[Dimension(‘z’)], label=’Vdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1264ff8d0>)The value dimensions defined as the list of dimensions used to describe the components of the data. If multiple value dimensions are supplied, a particular value dimension may be indexed by name after the key dimensions. Aliased with value_dimensions.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.RGB(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
Image
RGB represents a regularly spaced 2D grid of an underlying continuous space of RGB(A) (red, green, blue and alpha) color space values. The definition of the grid closely matches the semantics of an Image and in the simplest case the grid may be specified as a NxMx3 or NxMx4 array of values along with a bounds, but it may also be defined through explicit and regularly spaced x/y-coordinate arrays. The two most basic supported constructors of an RGB element therefore include:
RGB((X, Y, R, G, B))
where X is a 1D array of shape M, Y is a 1D array of shape N and R/G/B are 2D array of shape NxM, or equivalently:
RGB(Z, bounds=(x0, y0, x1, y1))
where Z is a 3D array of stacked R/G/B arrays with shape NxMx3/4 and the bounds define the (left, bottom, top, right) edges of the four corners of the grid. Other gridded formats which support declaring of explicit x/y-coordinate arrays such as xarray are also supported.
Note that the interpretation of the orientation changes depending on whether bounds or explicit coordinates are used.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.element.Element2D
: extentsholoviews.element.raster.Image
: kdims, datatype, bounds, rtolgroup
= param.String(allow_refs=False, constant=True, default=’RGB’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126582650>)A string describing the data wrapped by the object.
vdims
= param.List(allow_refs=False, bounds=(3, 4), default=[Dimension(‘R’), Dimension(‘G’), Dimension(‘B’)], label=’Vdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12658ef10>)The dimension description of the data held in the matrix. If an alpha channel is supplied, the defined alpha_dimension is automatically appended to this list.
alpha_dimension
= param.ClassSelector(allow_refs=False, class_=<class ‘holoviews.core.dimension.Dimension’>, default=Dimension(‘A’), label=’Alpha dimension’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126582650>)The alpha dimension definition to add the value dimensions if an alpha channel is supplied.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Returns a clone of the object with matching parameter values containing the specified args and kwargs.
If shared_data is set to True and no data explicitly supplied, the clone will share data with the original. May also supply a new_type, which will inherit all shared parameters.
- closest(coords=None, **kwargs)[source]#
Given a single coordinate or multiple coordinates as a tuple or list of tuples or keyword arguments matching the dimension closest will find the closest actual x/y coordinates.
- closest_cell_center(x, y)[source]#
Given arbitrary sheet coordinates, return the sheet coordinates of the center of the closest unit.
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- classmethod load_image(filename, height=1, array=False, bounds=None, bare=False, **kwargs)[source]#
Load an image from a file and return an RGB element or array
- Args:
filename: Filename of the image to be loaded height: Determines the bounds of the image where the width
is scaled relative to the aspect ratio of the image.
array: Whether to return an array (rather than RGB default) bounds: Bounds for the returned RGB (overrides height) bare: Whether to hide the axes kwargs: Additional kwargs to the RGB constructor
- Returns:
RGB element or array
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- matrix2sheet(float_row, float_col)[source]#
Convert a floating-point location (float_row,float_col) in matrix coordinates to its corresponding location (x,y) in sheet coordinates.
Valid for scalar or array float_row and float_col.
Inverse of sheet2matrix().
- matrixidx2sheet(row, col)[source]#
Return (x,y) where x and y are the floating point coordinates of the center of the given matrix cell (row,col). If the matrix cell represents a 0.2 by 0.2 region, then the center location returned would be 0.1,0.1.
NOTE: This is NOT the strict mathematical inverse of sheet2matrixidx(), because sheet2matrixidx() discards all but the integer portion of the continuous matrix coordinate.
Valid only for scalar or array row and col.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- property rgb#
Returns the corresponding RGB element.
Other than the updating parameter definitions, this is the only change needed to implemented an arbitrary colorspace as a subclass of RGB.
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_specs=None, **selection)[source]#
Allows selecting data by the slices, sets and scalar values along a particular dimension. The indices should be supplied as keywords mapping between the selected dimension and value. Additionally selection_specs (taking the form of a list of type.group.label strings, types or functions) may be supplied, which will ensure the selection is only applied if the specs match the selected object.
- property shape#
Returns the shape of the data.
- sheet2matrix(x, y)[source]#
Convert a point (x,y) in Sheet coordinates to continuous matrix coordinates.
Returns (float_row,float_col), where float_row corresponds to y, and float_col to x.
Valid for scalar or array x and y.
Note about Bounds For a Sheet with BoundingBox(points=((-0.5,-0.5),(0.5,0.5))) and density=3, x=-0.5 corresponds to float_col=0.0 and x=0.5 corresponds to float_col=3.0. float_col=3.0 is not inside the matrix representing this Sheet, which has the three columns (0,1,2). That is, x=-0.5 is inside the BoundingBox but x=0.5 is outside. Similarly, y=0.5 is inside (at row 0) but y=-0.5 is outside (at row 3) (it’s the other way round for y because the matrix row index increases as y decreases).
- sheet2matrixidx(x, y)[source]#
Convert a point (x,y) in sheet coordinates to the integer row and column index of the matrix cell in which that point falls, given a bounds and density. Returns (row,column).
Note that if coordinates along the right or bottom boundary are passed into this function, the returned matrix coordinate of the boundary will be just outside the matrix, because the right and bottom boundaries are exclusive.
Valid for scalar or array x and y.
- sheetcoordinates_of_matrixidx()[source]#
Return x,y where x is a vector of sheet coordinates representing the x-center of each matrix cell, and y represents the corresponding y-center of the cell.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- property xdensity#
The spacing between elements in an underlying matrix representation, in the x direction.
- property ydensity#
The spacing between elements in an underlying matrix representation, in the y direction.
- class holoviews.__init__.Raster(data, kdims=None, vdims=None, extents=None, **params)[source]#
Bases:
Element2D
Raster is a basic 2D element type for presenting either numpy or dask arrays as two dimensional raster images.
Arrays with a shape of (N,M) are valid inputs for Raster whereas subclasses of Raster (e.g. RGB) may also accept 3D arrays containing channel information.
Raster does not support slicing like the Image or RGB subclasses and the extents are in matrix coordinates if not explicitly specified.
Parameters inherited from:
group
= param.String(allow_refs=False, constant=True, default=’Raster’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1266224d0>)A string describing the data wrapped by the object.
kdims
= param.List(allow_refs=False, bounds=(2, 2), constant=True, default=[Dimension(‘x’), Dimension(‘y’)], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126623d90>)The label of the x- and y-dimension of the Raster in form of a string or dimension object.
vdims
= param.List(allow_refs=False, bounds=(1, None), default=[Dimension(‘z’)], label=’Vdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1266225d0>)The dimension description of the data held in the matrix.
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords, **kwargs)[source]#
Snap list or dict of coordinates to closest position.
- Args:
coords: List of 1D or 2D coordinates **kwargs: Coordinates specified as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dim, expanded=True, flat=True)[source]#
The set of samples available along a particular dimension.
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, **reduce_map)[source]#
Reduces the Raster using functions provided via the kwargs, where the keyword is the dimension to be reduced. Optionally a label_prefix can be provided to prepend to the result Element label.
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, **sample_values)[source]#
Sample the Raster along one or both of its dimensions, returning a reduced dimensionality type, which is either a ItemTable, Curve or Scatter. If two dimension samples and a new_xaxis is provided the sample will be the value of the sampled unit indexed by the value in the new_xaxis tuple.
- select(selection_specs=None, **kwargs)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
- Args:
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Rectangles(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
SelectionGeomExpr
,Geometry
Rectangles represent a collection of axis-aligned rectangles in 2D space.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.element.Element2D
: extentsholoviews.core.data.Dataset
: datatypegroup
= param.String(allow_refs=False, constant=True, default=’Rectangles’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126630590>)A string describing the data wrapped by the object.
kdims
= param.List(allow_refs=False, bounds=(4, 4), constant=True, default=[Dimension(‘x0’), Dimension(‘y0’), Dimension(‘x1’), Dimension(‘y1’)], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126675f10>)The key dimensions of the Rectangles element represent the bottom-left (x0, y0) and top right (x1, y1) coordinates of each box.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Sankey(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
Graph
Sankey is an acyclic, directed Graph type that represents the flow of some quantity between its nodes.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.element.Element2D
: extentsholoviews.core.data.Dataset
: datatypegroup
= param.String(allow_refs=False, constant=True, default=’Sankey’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12679e6d0>)A string describing the data wrapped by the object.
vdims
= param.List(allow_refs=False, bounds=(0, None), default=[Dimension(‘Value’)], label=’Vdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12671cf50>)The value dimensions defined as the list of dimensions used to describe the components of the data. If multiple value dimensions are supplied, a particular value dimension may be indexed by name after the key dimensions. Aliased with value_dimensions.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- property edgepaths#
Returns the fixed EdgePaths or computes direct connections between supplied nodes.
- classmethod from_networkx(G, positions, nodes=None, **kwargs)[source]#
Generate a HoloViews Graph from a networkx.Graph object and networkx layout function or dictionary of node positions. Any keyword arguments will be passed to the layout function. By default it will extract all node and edge attributes from the networkx.Graph but explicit node information may also be supplied. Any non-scalar attributes, such as lists or dictionaries will be ignored.
- Args:
G (networkx.Graph): Graph to convert to Graph element positions (dict or callable): Node positions
Node positions defined as a dictionary mapping from node id to (x, y) tuple or networkx layout function which computes a positions dictionary
kwargs (dict): Keyword arguments for layout function
- Returns:
Graph element
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- property nodes#
Computes the node positions the first time they are requested if no explicit node information was supplied.
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dimension, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, selection_mode='edges', **selection)[source]#
Allows selecting data by the slices, sets and scalar values along a particular dimension. The indices should be supplied as keywords mapping between the selected dimension and value. Additionally selection_specs (taking the form of a list of type.group.label strings, types or functions) may be supplied, which will ensure the selection is only applied if the specs match the selected object.
Selecting by a node dimensions selects all edges and nodes that are connected to the selected nodes. To select only edges between the selected nodes set the selection_mode to ‘nodes’.
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Scatter(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
Selection1DExpr
,Chart
Scatter is a Chart element representing a set of points in a 1D coordinate system where the key dimension maps to the points location along the x-axis while the first value dimension represents the location of the point along the y-axis.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.element.Element2D
: extentsholoviews.core.data.Dataset
: datatypeholoviews.element.chart.Chart
: kdims, vdimsgroup
= param.String(allow_refs=False, constant=True, default=’Scatter’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12677a2d0>)A string describing the data wrapped by the object.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Scatter3D(data=None, kdims=None, vdims=None, **kwargs)[source]#
-
Scatter3D is a 3D element representing the position of a collection of coordinates in a 3D space. The key dimensions represent the position of each coordinate along the x-, y- and z-axis.
Scatter3D is not available for the default Bokeh backend.
Example - Matplotlib#
import holoviews as hv from bokeh.sampledata.iris import flowers hv.extension("matplotlib") hv.Scatter3D( flowers, kdims=["sepal_length", "sepal_width", "petal_length"] ).opts( color="petal_width", alpha=0.7, size=5, cmap="fire", marker='^' )
Example - Plotly#
import holoviews as hv from bokeh.sampledata.iris import flowers hv.extension("plotly") hv.Scatter3D( flowers, kdims=["sepal_length", "sepal_width", "petal_length"] ).opts( color="petal_width", alpha=0.7, size=5, cmap="Portland", colorbar=True, marker="circle", )
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.data.Dataset
: datatypeholoviews.core.element.Element3D
: extentsgroup
= param.String(allow_refs=False, constant=True, default=’Scatter3D’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126819050>)A string describing the data wrapped by the object.
kdims
= param.List(allow_refs=False, bounds=(3, 3), default=[Dimension(‘x’), Dimension(‘y’), Dimension(‘z’)], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12681a750>)The key dimensions of a geometry represent the x- and y- coordinates in a 2D space.
vdims
= param.List(allow_refs=False, bounds=(0, None), default=[], label=’Vdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126818950>)Scatter3D can have optional value dimensions, which may be mapped onto color and size.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Segments(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
SelectionGeomExpr
,Geometry
Segments represent a collection of lines in 2D space.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.element.Element2D
: extentsholoviews.core.data.Dataset
: datatypegroup
= param.String(allow_refs=False, constant=True, default=’Segments’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1268910d0>)A string describing the data wrapped by the object.
kdims
= param.List(allow_refs=False, bounds=(4, 4), constant=True, default=[Dimension(‘x0’), Dimension(‘y0’), Dimension(‘x1’), Dimension(‘y1’)], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126892e10>)Segments represent lines given by x- and y- coordinates in 2D space.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Slope(slope, y_intercept, kdims=None, vdims=None, **params)[source]#
Bases:
Annotation
A line drawn with arbitrary slope and y-intercept
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdims, vdimsholoviews.core.element.Element2D
: extentsholoviews.element.annotation.Annotation
: group, kdimsslope
= param.Number(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Slope’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1269202d0>)y_intercept
= param.Number(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Y intercept’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126922c90>)- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(*args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords, **kwargs)[source]#
Snap list or dict of coordinates to closest position.
- Args:
coords: List of 1D or 2D coordinates **kwargs: Coordinates specified as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- classmethod from_scatter(element, **kwargs)[source]#
Returns a Slope element given an element of x/y-coordinates
Computes the slope and y-intercept from an element containing x- and y-coordinates.
- Args:
element: Element to compute slope from kwargs: Keyword arguments to pass to the Slope element
- Returns:
Slope element
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- range(dimension, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reduction)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The element after reductions have been applied.
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=False, **sample_values)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_specs=None, **kwargs)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
- Args:
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Spikes(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
Selection1DExpr
,Chart
Spikes is a Chart element which represents a number of discrete spikes, events or observations in a 1D coordinate system. The key dimension therefore represents the position of each spike along the x-axis while the first value dimension, if defined, controls the height along the y-axis. It may therefore be used to visualize the distribution of discrete events, representing a rug plot, or to draw the strength some signal.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.element.Element2D
: extentsholoviews.core.data.Dataset
: datatypegroup
= param.String(allow_refs=False, constant=True, default=’Spikes’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126908790>)A string describing the data wrapped by the object.
kdims
= param.List(allow_refs=False, bounds=(1, 1), default=[Dimension(‘x’)], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12697da90>)The key dimension(s) of a Chart represent the independent variable(s).
vdims
= param.List(allow_refs=False, bounds=(0, None), default=[], label=’Vdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12696f310>)The value dimensions of the Chart, usually corresponding to a number of dependent variables.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Spline(spline_points, **params)[source]#
Bases:
Annotation
Draw a spline using the given handle coordinates and handle codes. The constructor accepts a tuple in format (coords, codes).
Follows format of matplotlib spline definitions as used in matplotlib.path.Path with the following codes:
Path.STOP : 0 Path.MOVETO : 1 Path.LINETO : 2 Path.CURVE3 : 3 Path.CURVE4 : 4 Path.CLOSEPLOY: 79
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdims, vdimsholoviews.core.element.Element2D
: extentsgroup
= param.String(allow_refs=False, constant=True, default=’Spline’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126a00290>)A string describing the data wrapped by the object.
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- closest(coords, **kwargs)[source]#
Snap list or dict of coordinates to closest position.
- Args:
coords: List of 1D or 2D coordinates **kwargs: Coordinates specified as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- range(dimension, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reduction)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The element after reductions have been applied.
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=False, **sample_values)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_specs=None, **kwargs)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
- Args:
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Spread(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
ErrorBars
Spread is a Chart element representing a spread of values or confidence band in a 1D coordinate system. The key dimension(s) corresponds to the location along the x-axis and the value dimensions define the location along the y-axis as well as the symmetric or asymmetric spread.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.element.Element2D
: extentsholoviews.core.data.Dataset
: datatypeholoviews.element.chart.Chart
: kdimsholoviews.element.chart.ErrorBars
: vdims, horizontalgroup
= param.String(allow_refs=False, constant=True, default=’Spread’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126a3a450>)A string describing the quantity measured by the ErrorBars object.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
Range of the y-dimension includes the symmetric or asymmetric error.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Store[source]#
Bases:
object
The Store is what links up HoloViews objects to their corresponding options and to the appropriate classes of the chosen backend (e.g. for rendering).
In addition, Store supports pickle operations that automatically pickle and unpickle the corresponding options for a HoloViews object.
- classmethod add_style_opts(component, new_options, backend=None)[source]#
Given a component such as an Element (e.g. Image, Curve) or a container (e.g. Layout) specify new style options to be accepted by the corresponding plotting class.
Note: This is supplied for advanced users who know which additional style keywords are appropriate for the corresponding plotting class.
- classmethod dump(obj, file, protocol=0)[source]#
Equivalent to pickle.dump except that the HoloViews option tree is saved appropriately.
- classmethod dumps(obj, protocol=0)[source]#
Equivalent to pickle.dumps except that the HoloViews option tree is saved appropriately.
- classmethod info(obj, ansi=True, backend='matplotlib', visualization=True, recursive=False, pattern=None, elements=None)[source]#
Show information about a particular object or component class including the applicable style and plot options. Returns None if the object is not parameterized.
- classmethod load(filename)[source]#
Equivalent to pickle.load except that the HoloViews trees is restored appropriately.
- classmethod loaded_backends()[source]#
Returns a list of the backends that have been loaded, based on the available OptionTrees.
- classmethod loads(pickle_string)[source]#
Equivalent to pickle.loads except that the HoloViews trees is restored appropriately.
- classmethod lookup(backend, obj)[source]#
Given an object, lookup the corresponding customized option tree if a single custom tree is applicable.
- output_settings[source]#
alias of
OutputSettings
- classmethod register(associations, backend, style_aliases=None)[source]#
Register the supplied dictionary of associations between elements and plotting classes to the specified backend.
- classmethod render(obj)[source]#
Using any display hooks that have been registered, render the object to a dictionary of MIME types and metadata information.
- classmethod set_current_backend(backend)[source]#
Use this method to set the backend to run the switch hooks
- class holoviews.__init__.StoreOptions[source]#
Bases:
object
A collection of utilities for advanced users for creating and setting customized option trees on the Store. Designed for use by either advanced users or the %opts line and cell magics which use this machinery.
This class also holds general classmethods for working with OptionTree instances: as OptionTrees are designed for attribute access it is best to minimize the number of methods implemented on that class and implement the necessary utilities on StoreOptions instead.
Lastly this class offers a means to record all OptionErrors generated by an option specification. This is used for validation purposes.
- classmethod apply_customizations(spec, options)[source]#
Apply the given option specs to the supplied options tree.
- classmethod capture_ids(obj)[source]#
Given an list of ids, capture a list of ids that can be restored using the restore_ids.
- classmethod create_custom_trees(obj, options=None, backend=None)[source]#
Returns the appropriate set of customized subtree clones for an object, suitable for merging with Store.custom_options (i.e with the ids appropriately offset). Note if an object has no integer ids a new OptionTree is built.
The id_mapping return value is a list mapping the ids that need to be matched as set to their new values.
- classmethod expand_compositor_keys(spec)[source]#
Expands compositor definition keys into {type}.{group} keys. For instance a compositor operation returning a group string ‘Image’ of element type RGB expands to ‘RGB.Image’.
- classmethod id_offset()[source]#
Compute an appropriate offset for future id values given the set of ids currently defined across backends.
- classmethod merge_options(groups, options=None, **kwargs)[source]#
Given a full options dictionary and options groups specified as a keywords, return the full set of merged options:
>>> options={'Curve':{'style':dict(color='b')}} >>> style={'Curve':{'linewidth':10 }} >>> merged = StoreOptions.merge_options(['style'], options, style=style) >>> sorted(merged['Curve']['style'].items()) [('color', 'b'), ('linewidth', 10)]
- classmethod options(obj, options=None, **kwargs)[source]#
Context-manager for temporarily setting options on an object (if options is None, no options will be set) . Once the context manager exits, both the object and the Store will be left in exactly the same state they were in before the context manager was used.
See holoviews.core.options.set_options function for more information on the options specification format.
- classmethod propagate_ids(obj, match_id, new_id, applied_keys, backend=None)[source]#
Recursively propagate an id through an object for components matching the applied_keys. This method can only be called if there is a tree with a matching id in Store.custom_options
- classmethod record_skipped_option(error)[source]#
Record the OptionError associated with a skipped option if currently recording
- classmethod restore_ids(obj, ids)[source]#
Given an list of ids as captured with capture_ids, restore the ids. Note the structure of an object must not change between the calls to capture_ids and restore_ids.
- classmethod set_options(obj, options=None, backend=None, **kwargs)[source]#
Pure Python function for customize HoloViews objects in terms of their style, plot and normalization options.
The options specification is a dictionary containing the target for customization as a {type}.{group}.{label} keys. An example of such a key is ‘Image’ which would customize all Image components in the object. The key ‘Image.Channel’ would only customize Images in the object that have the group ‘Channel’.
The corresponding value is then a list of Option objects specified with an appropriate category (‘plot’, ‘style’ or ‘norm’). For instance, using the keys described above, the specs could be:
{‘Image:[Options(‘style’, cmap=’jet’)]}
Or setting two types of option at once:
- {‘Image.Channel’:[Options(‘plot’, size=50),
Options(‘style’, cmap=’Blues’)]}
Relationship to the %%opts magic#
This function matches the functionality supplied by the %%opts cell magic in the IPython extension. In fact, you can use the same syntax as the IPython cell magic to achieve the same customization as shown above:
from holoviews.util.parser import OptsSpec set_options(my_image, OptsSpec.parse(“Image (cmap=’jet’)”))
Then setting both plot and style options:
set_options(my_image, OptsSpec.parse(“Image [size=50] (cmap=’Blues’)”))
- classmethod start_recording_skipped()[source]#
Start collecting OptionErrors for all skipped options recorded with the record_skipped_option method
- classmethod state(obj, state=None)[source]#
Method to capture and restore option state. When called without any state supplied, the current state is returned. Then if this state is supplied back in a later call using the same object, the original state is restored.
- classmethod stop_recording_skipped()[source]#
Stop collecting OptionErrors recorded with the record_skipped_option method and return them
- classmethod tree_to_dict(tree)[source]#
Given an OptionTree, convert it into the equivalent dictionary format.
- classmethod update_backends(id_mapping, custom_trees, backend=None)[source]#
Given the id_mapping from previous ids to new ids and the new custom tree dictionary, update the current backend with the supplied trees and update the keys in the remaining backends to stay linked with the current object.
- classmethod validate_spec(spec, backends=None)[source]#
Given a specification, validated it against the options tree for the specified backends by raising OptionError for invalid options. If backends is None, validates against all the currently loaded backend.
Only useful when invalid keywords generate exceptions instead of skipping, i.e. Options.skip_invalid is False.
- class holoviews.__init__.Surface(data=None, kdims=None, vdims=None, **kwargs)[source]#
-
A Surface represents a regularly sampled 2D grid with associated values defining the height along the z-axis. The key dimensions of a Surface represent the 2D coordinates along the x- and y-axes while the value dimension declares the height at each grid location.
The data of a Surface is usually defined as a 2D array of values and either a bounds tuple defining the extent in the 2D space or explicit x- and y-coordinate arrays.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.element.raster.Image
: datatype, bounds, rtolgroup
= param.String(allow_refs=False, constant=True, default=’Surface’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126a48590>)A string describing the data wrapped by the object.
kdims
= param.List(allow_refs=False, bounds=(2, 2), default=[Dimension(‘x’), Dimension(‘y’)], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126b72450>)The Surface x and y dimensions of the space defined by the supplied extent.
vdims
= param.List(allow_refs=False, bounds=(1, 1), default=[Dimension(‘z’)], label=’Vdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126b60210>)The Surface height dimension.
extents
= param.Tuple(allow_refs=False, default=(None, None, None, None, None, None), label=’Extents’, length=6, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126b63a50>)Allows overriding the extents of the Element in 3D space defined as (xmin, ymin, zmin, xmax, ymax, zmax).
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Returns a clone of the object with matching parameter values containing the specified args and kwargs.
If shared_data is set to True and no data explicitly supplied, the clone will share data with the original. May also supply a new_type, which will inherit all shared parameters.
- closest(coords=None, **kwargs)[source]#
Given a single coordinate or multiple coordinates as a tuple or list of tuples or keyword arguments matching the dimension closest will find the closest actual x/y coordinates.
- closest_cell_center(x, y)[source]#
Given arbitrary sheet coordinates, return the sheet coordinates of the center of the closest unit.
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- matrix2sheet(float_row, float_col)[source]#
Convert a floating-point location (float_row,float_col) in matrix coordinates to its corresponding location (x,y) in sheet coordinates.
Valid for scalar or array float_row and float_col.
Inverse of sheet2matrix().
- matrixidx2sheet(row, col)[source]#
Return (x,y) where x and y are the floating point coordinates of the center of the given matrix cell (row,col). If the matrix cell represents a 0.2 by 0.2 region, then the center location returned would be 0.1,0.1.
NOTE: This is NOT the strict mathematical inverse of sheet2matrixidx(), because sheet2matrixidx() discards all but the integer portion of the continuous matrix coordinate.
Valid only for scalar or array row and col.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_specs=None, **selection)[source]#
Allows selecting data by the slices, sets and scalar values along a particular dimension. The indices should be supplied as keywords mapping between the selected dimension and value. Additionally selection_specs (taking the form of a list of type.group.label strings, types or functions) may be supplied, which will ensure the selection is only applied if the specs match the selected object.
- property shape#
Returns the shape of the data.
- sheet2matrix(x, y)[source]#
Convert a point (x,y) in Sheet coordinates to continuous matrix coordinates.
Returns (float_row,float_col), where float_row corresponds to y, and float_col to x.
Valid for scalar or array x and y.
Note about Bounds For a Sheet with BoundingBox(points=((-0.5,-0.5),(0.5,0.5))) and density=3, x=-0.5 corresponds to float_col=0.0 and x=0.5 corresponds to float_col=3.0. float_col=3.0 is not inside the matrix representing this Sheet, which has the three columns (0,1,2). That is, x=-0.5 is inside the BoundingBox but x=0.5 is outside. Similarly, y=0.5 is inside (at row 0) but y=-0.5 is outside (at row 3) (it’s the other way round for y because the matrix row index increases as y decreases).
- sheet2matrixidx(x, y)[source]#
Convert a point (x,y) in sheet coordinates to the integer row and column index of the matrix cell in which that point falls, given a bounds and density. Returns (row,column).
Note that if coordinates along the right or bottom boundary are passed into this function, the returned matrix coordinate of the boundary will be just outside the matrix, because the right and bottom boundaries are exclusive.
Valid for scalar or array x and y.
- sheetcoordinates_of_matrixidx()[source]#
Return x,y where x is a vector of sheet coordinates representing the x-center of each matrix cell, and y represents the corresponding y-center of the cell.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- property xdensity#
The spacing between elements in an underlying matrix representation, in the x direction.
- property ydensity#
The spacing between elements in an underlying matrix representation, in the y direction.
- class holoviews.__init__.Table(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
SelectionIndexExpr
,Dataset
,Tabular
Table is a Dataset type, which gets displayed in a tabular format and is convertible to most other Element types.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdims, kdims, vdimsholoviews.core.data.Dataset
: datatypegroup
= param.String(allow_refs=False, constant=True, default=’Table’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126b4fcd0>)The group is used to describe the Table.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- cell_type(row, col)[source]#
Type of the table cell, either ‘data’ or ‘heading’
- Args:
row (int): Integer index of table row col (int): Integer index of table column
- Returns:
Type of the table cell, either ‘data’ or ‘heading’
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- property cols#
Number of columns in table
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- pprint_cell(row, col)[source]#
Formatted contents of table cell.
- Args:
row (int): Integer index of table row col (int): Integer index of table column
- Returns:
Formatted table cell contents
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- property rows#
Number of rows in table (including header)
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Text(x, y, text, fontsize=12, halign='center', valign='center', rotation=0, **params)[source]#
Bases:
Annotation
Draw a text annotation at the specified position with custom fontsize, alignment and rotation.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdims, vdimsholoviews.core.element.Element2D
: extentsgroup
= param.String(allow_refs=False, constant=True, default=’Text’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126d3c050>)A string describing the data wrapped by the object.
x
= param.ClassSelector(allow_refs=False, class_=(<class ‘numbers.Number’>, <class ‘str’>, <class ‘numpy.datetime64’>, <class ‘datetime.datetime’>, <class ‘datetime.date’>, <class ‘datetime.time’>, <class ‘pandas._libs.tslibs.timestamps.Timestamp’>, <class ‘pandas.core.dtypes.dtypes.DatetimeTZDtype’>, <class ‘pandas._libs.tslibs.period.Period’>, <class ‘cftime._cftime.datetime’>), default=0, label=’X’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126d3fed0>)The x-position of the arrow which make be numeric or a timestamp.
y
= param.ClassSelector(allow_refs=False, class_=(<class ‘numbers.Number’>, <class ‘str’>, <class ‘numpy.datetime64’>, <class ‘datetime.datetime’>, <class ‘datetime.date’>, <class ‘datetime.time’>, <class ‘pandas._libs.tslibs.timestamps.Timestamp’>, <class ‘pandas.core.dtypes.dtypes.DatetimeTZDtype’>, <class ‘pandas._libs.tslibs.period.Period’>, <class ‘cftime._cftime.datetime’>), default=0, label=’Y’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126d3c050>)The y-position of the arrow which make be numeric or a timestamp.
text
= param.String(allow_refs=False, default=’’, label=’Text’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126d3fb90>)The text to be displayed.
fontsize
= param.Number(allow_refs=False, default=12, inclusive_bounds=(True, True), label=’Fontsize’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126d401d0>)Font size of the text.
rotation
= param.Number(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Rotation’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126d40810>)Text rotation angle in degrees.
halign
= param.ObjectSelector(allow_refs=False, default=’center’, label=’Halign’, names={}, nested_refs=False, objects=[‘left’, ‘right’, ‘center’], rx=<param.reactive.reactive_ops object at 0x126d3e7d0>)The horizontal alignment position of the displayed text. Allowed values are ‘left’, ‘right’ and ‘center’.
valign
= param.ObjectSelector(allow_refs=False, default=’center’, label=’Valign’, names={}, nested_refs=False, objects=[‘top’, ‘bottom’, ‘center’], rx=<param.reactive.reactive_ops object at 0x126d3fed0>)The vertical alignment position of the displayed text. Allowed values are ‘center’, ‘top’ and ‘bottom’.
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(*args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords, **kwargs)[source]#
Snap list or dict of coordinates to closest position.
- Args:
coords: List of 1D or 2D coordinates **kwargs: Coordinates specified as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- range(dimension, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reduction)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The element after reductions have been applied.
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=False, **sample_values)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_specs=None, **kwargs)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
- Args:
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Tiles(data=None, kdims=None, vdims=None, **params)[source]#
Bases:
Element2D
The Tiles element represents tile sources, specified as URL containing different template variables or xyzservices.TileProvider. These variables correspond to three different formats for specifying the spatial location and zoom level of the requested tiles:
Web mapping tiles sources containing {x}, {y}, and {z} variables
Bounding box tile sources containing {XMIN}, {XMAX}, {YMIN}, {YMAX} variables
Quadkey tile sources containing a {Q} variable
Tiles are defined in a pseudo-Mercator projection (EPSG:3857) defined as eastings and northings. Any data overlaid on a tile source therefore has to be defined in those coordinates or be projected (e.g. using GeoViews).
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdims, vdimsholoviews.core.element.Element2D
: extentsgroup
= param.String(allow_refs=False, constant=True, default=’Tiles’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126db7090>)A string describing the data wrapped by the object.
kdims
= param.List(allow_refs=False, bounds=(2, 2), constant=True, default=[Dimension(‘x’), Dimension(‘y’)], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126db5cd0>)The key dimensions of a geometry represent the x- and y- coordinates in a 2D space.
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords, **kwargs)[source]#
Snap list or dict of coordinates to closest position.
- Args:
coords: List of 1D or 2D coordinates **kwargs: Coordinates specified as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- static easting_northing_to_lon_lat(easting, northing)[source]#
Projects the given easting, northing values into longitude, latitude coordinates.
See docstring for holoviews.util.transform.easting_northing_to_lon_lat for more information
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- static lon_lat_to_easting_northing(longitude, latitude)[source]#
Projects the given longitude, latitude values into Web Mercator (aka Pseudo-Mercator or EPSG:3857) coordinates.
See docstring for holoviews.util.transform.lon_lat_to_easting_northing for more information
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reduction)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The element after reductions have been applied.
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=False, **sample_values)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_specs=None, **kwargs)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
- Args:
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.TriMesh(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
Graph
A TriMesh represents a mesh of triangles represented as the simplices and nodes. The simplices represent a indices into the nodes array. The mesh therefore follows a datastructure very similar to a graph, with the abstract connectivity between nodes stored on the TriMesh element itself, the node positions stored on a Nodes element and the concrete paths making up each triangle generated when required by accessing the edgepaths.
Unlike a Graph each simplex is represented as the node indices of the three corners of each triangle.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdims, vdimsholoviews.core.element.Element2D
: extentsholoviews.core.data.Dataset
: datatypegroup
= param.String(allow_refs=False, constant=True, default=’TriMesh’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126c08ed0>)A string describing the data wrapped by the object.
kdims
= param.List(allow_refs=False, bounds=(3, 3), default=[‘node1’, ‘node2’, ‘node3’], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126c68210>)Dimensions declaring the node indices of each triangle.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- property edgepaths#
Returns the EdgePaths by generating a triangle for each simplex.
- classmethod from_networkx(G, positions, nodes=None, **kwargs)[source]#
Generate a HoloViews Graph from a networkx.Graph object and networkx layout function or dictionary of node positions. Any keyword arguments will be passed to the layout function. By default it will extract all node and edge attributes from the networkx.Graph but explicit node information may also be supplied. Any non-scalar attributes, such as lists or dictionaries will be ignored.
- Args:
G (networkx.Graph): Graph to convert to Graph element positions (dict or callable): Node positions
Node positions defined as a dictionary mapping from node id to (x, y) tuple or networkx layout function which computes a positions dictionary
kwargs (dict): Keyword arguments for layout function
- Returns:
Graph element
- classmethod from_vertices(data)[source]#
Uses Delauney triangulation to compute triangle simplices for each point.
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- property nodes#
Computes the node positions the first time they are requested if no explicit node information was supplied.
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dimension, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_specs=None, **selection)[source]#
Allows selecting data by the slices, sets and scalar values along a particular dimension. The indices should be supplied as keywords mapping between the selected dimension and value. Additionally selection_specs (taking the form of a list of type.group.label strings, types or functions) may be supplied, which will ensure the selection is only applied if the specs match the selected object.
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.TriSurface(data=None, kdims=None, vdims=None, **kwargs)[source]#
-
TriSurface represents a set of coordinates in 3D space which define a surface via a triangulation algorithm (usually Delauney triangulation). They key dimensions of a TriSurface define the position of each point along the x-, y- and z-axes, while value dimensions can provide additional information about each point.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.data.Dataset
: datatypeholoviews.core.element.Element3D
: extentsgroup
= param.String(allow_refs=False, constant=True, default=’TriSurface’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126cdf590>)A string describing the data wrapped by the object.
kdims
= param.List(allow_refs=False, bounds=(3, 3), default=[Dimension(‘x’), Dimension(‘y’), Dimension(‘z’)], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126ca48d0>)The key dimensions of a TriSurface represent the 3D coordinates of each point.
vdims
= param.List(allow_refs=False, bounds=(0, None), default=[], label=’Vdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126cdf590>)The value dimensions of a TriSurface can provide additional information about each 3D coordinate.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.VLine(x, **params)[source]#
Bases:
Annotation
Vertical line annotation at the given position.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdims, vdimsholoviews.core.element.Element2D
: extentsgroup
= param.String(allow_refs=False, constant=True, default=’VLine’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126f2ed50>)A string describing the data wrapped by the object.
x
= param.ClassSelector(allow_refs=False, class_=(<class ‘numbers.Number’>, <class ‘numpy.datetime64’>, <class ‘datetime.datetime’>, <class ‘datetime.date’>, <class ‘datetime.time’>, <class ‘pandas._libs.tslibs.timestamps.Timestamp’>, <class ‘pandas.core.dtypes.dtypes.DatetimeTZDtype’>, <class ‘pandas._libs.tslibs.period.Period’>, <class ‘cftime._cftime.datetime’>), default=0, label=’X’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126f20110>)The x-position of the VLine which make be numeric or a timestamp.
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(*args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords, **kwargs)[source]#
Snap list or dict of coordinates to closest position.
- Args:
coords: List of 1D or 2D coordinates **kwargs: Coordinates specified as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- range(dimension, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reduction)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The element after reductions have been applied.
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=False, **sample_values)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_specs=None, **kwargs)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
- Args:
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.VLines(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
VectorizedAnnotation
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdims, vdimsholoviews.core.element.Element2D
: extentsholoviews.core.data.Dataset
: datatypegroup
= param.String(allow_refs=False, constant=True, default=’VLines’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126f6fed0>)A string describing the data wrapped by the object.
kdims
= param.List(allow_refs=False, bounds=(1, 1), default=[Dimension(‘x’)], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126f89cd0>)The key dimensions defined as list of dimensions that may be used in indexing (and potential slicing) semantics. The order of the dimensions listed here determines the semantics of each component of a multi-dimensional indexing operation. Aliased with key_dimensions.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.VSpan(x1=None, x2=None, **params)[source]#
Bases:
Annotation
Vertical span annotation at the given position.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdims, vdimsholoviews.core.element.Element2D
: extentsgroup
= param.String(allow_refs=False, constant=True, default=’VSpan’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126ff1690>)A string describing the data wrapped by the object.
x1
= param.ClassSelector(allow_None=True, allow_refs=False, class_=(<class ‘numbers.Number’>, <class ‘numpy.datetime64’>, <class ‘datetime.datetime’>, <class ‘datetime.date’>, <class ‘datetime.time’>, <class ‘pandas._libs.tslibs.timestamps.Timestamp’>, <class ‘pandas.core.dtypes.dtypes.DatetimeTZDtype’>, <class ‘pandas._libs.tslibs.period.Period’>, <class ‘cftime._cftime.datetime’>), default=0, label=’X1’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1270118d0>)The start x-position of the VSpan which must be numeric or a timestamp.
x2
= param.ClassSelector(allow_None=True, allow_refs=False, class_=(<class ‘numbers.Number’>, <class ‘numpy.datetime64’>, <class ‘datetime.datetime’>, <class ‘datetime.date’>, <class ‘datetime.time’>, <class ‘pandas._libs.tslibs.timestamps.Timestamp’>, <class ‘pandas.core.dtypes.dtypes.DatetimeTZDtype’>, <class ‘pandas._libs.tslibs.period.Period’>, <class ‘cftime._cftime.datetime’>), default=0, label=’X2’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x126ff3990>)The end x-position of the VSpan which must be numeric or a timestamp.
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(*args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords, **kwargs)[source]#
Snap list or dict of coordinates to closest position.
- Args:
coords: List of 1D or 2D coordinates **kwargs: Coordinates specified as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- range(dimension, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reduction)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The element after reductions have been applied.
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=False, **sample_values)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_specs=None, **kwargs)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
- Args:
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.VSpans(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
VectorizedAnnotation
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdims, vdimsholoviews.core.element.Element2D
: extentsholoviews.core.data.Dataset
: datatypegroup
= param.String(allow_refs=False, constant=True, default=’VSpans’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1270583d0>)A string describing the data wrapped by the object.
kdims
= param.List(allow_refs=False, bounds=(2, 2), default=[Dimension(‘x0’), Dimension(‘x1’)], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12705b310>)The key dimensions defined as list of dimensions that may be used in indexing (and potential slicing) semantics. The order of the dimensions listed here determines the semantics of each component of a multi-dimensional indexing operation. Aliased with key_dimensions.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.VectorField(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
Selection2DExpr
,Geometry
A VectorField represents a set of vectors in 2D space with an associated angle, as well as an optional magnitude and any number of other value dimensions. The angles are assumed to be defined in radians and by default the magnitude is assumed to be normalized to be between 0 and 1.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.element.Element2D
: extentsholoviews.core.data.Dataset
: datatypegroup
= param.String(allow_refs=False, constant=True, default=’VectorField’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1270ec550>)A string describing the data wrapped by the object.
vdims
= param.List(allow_refs=False, bounds=(1, None), default=[Dimension(‘Angle’), Dimension(‘Magnitude’)], label=’Vdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1270eea90>)Value dimensions can be associated with a geometry.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.VectorizedAnnotation(data=None, kdims=None, vdims=None, **kwargs)[source]#
-
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdims, kdims, vdimsholoviews.core.element.Element2D
: extentsholoviews.core.data.Dataset
: group, datatype- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.Violin(data=None, kdims=None, vdims=None, **kwargs)[source]#
Bases:
BoxWhisker
Violin elements represent data as 1D distributions visualized as a kernel-density estimate. It may have a single value dimension and any number of key dimensions declaring the grouping of each violin.
Parameters inherited from:
holoviews.core.dimension.LabelledData
: labelholoviews.core.dimension.Dimensioned
: cdimsholoviews.core.element.Element2D
: extentsholoviews.core.data.Dataset
: datatypeholoviews.element.stats.BoxWhisker
: kdims, vdimsgroup
= param.String(allow_refs=False, constant=True, default=’Violin’, label=’Group’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1271e6890>)A string describing the data wrapped by the object.
- add_dimension(dimension, dim_pos, dim_val, vdim=False, **kwargs)[source]#
Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in the key dimensions and a key value scalar or array of values, matching the length or shape of the Dataset.
- Args:
dimension: Dimension or dimension spec to add dim_pos (int): Integer index to insert dimension at dim_val (scalar or ndarray): Dimension value(s) to add vdim: Disabled, this type does not have value dimensions **kwargs: Keyword arguments passed to the cloned element
- Returns:
Cloned object containing the new dimension
- aggregate(dimensions=None, function=None, spreadfn=None, **kwargs)[source]#
Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined function or dim_transform specified as a tuple of the transformed dimension name and dim transform.
- Args:
- dimensions: Dimension(s) to aggregate on
Default to all key dimensions
- function: Aggregation function or transform to apply
Supports both simple functions and dimension transforms
- spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **kwargs: Keyword arguments either passed to the aggregation function
or to create new names for the transformed variables
- Returns:
Returns the aggregated Dataset
- array(dimensions=None)[source]#
Convert dimension values to columnar array.
- Args:
dimensions: List of dimensions to return
- Returns:
Array of columns corresponding to each dimension
- clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#
Clones the object, overriding data and parameters.
- Args:
data: New data replacing the existing data shared_data (bool, optional): Whether to use existing data new_type (optional): Type to cast object to link (bool, optional): Whether clone should be linked
Determines whether Streams and Links attached to original object will be inherited.
*args: Additional arguments to pass to constructor **overrides: New keyword arguments to pass to constructor
- Returns:
Cloned object
- closest(coords=None, **kwargs)[source]#
Snaps coordinate(s) to closest coordinate in Dataset
- Args:
coords: List of coordinates expressed as tuples **kwargs: Coordinates defined as keyword pairs
- Returns:
List of tuples of the snapped coordinates
- Raises:
NotImplementedError: Raised if snapping is not supported
- columns(dimensions=None)[source]#
Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension of the element.
- Args:
dimensions: Dimensions to return as columns
- Returns:
Dictionary of arrays for each dimension
- compute()[source]#
Computes the data to a data format that stores the daata in memory, e.g. a Dask dataframe or array is converted to a Pandas DataFrame or NumPy array.
- Returns:
Dataset with the data stored in in-memory format
- property dataset#
The Dataset that this object was created from
- property ddims#
The list of deep dimensions
- dframe(dimensions=None, multi_index=False)[source]#
Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension, either completely flat or indexed by key dimensions.
- Args:
dimensions: Dimensions to return as columns multi_index: Convert key dimensions to (multi-)index
- Returns:
DataFrame of columns corresponding to each dimension
- dimension_values(dimension, expanded=True, flat=True)[source]#
Return the values along the requested dimension.
- Args:
dimension: The dimension to return values for expanded (bool, optional): Whether to expand values
Whether to return the expanded values, behavior depends on the type of data:
Columnar: If false returns unique values
Geometry: If false returns scalar values per geometry
Gridded: If false returns 1D coordinates
flat (bool, optional): Whether to flatten array
- Returns:
NumPy array of values along the requested dimension
- dimensions(selection='all', label=False)[source]#
Lists the available dimensions on the object
Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.
- Args:
- selection: Type of dimensions to return
The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.
- label: Whether to return the name, label or Dimension
Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).
- Returns:
List of Dimension objects or their names or labels
- get_dimension(dimension, default=None, strict=False)[source]#
Get a Dimension object by name or index.
- Args:
dimension: Dimension to look up by name or integer index default (optional): Value returned if Dimension not found strict (bool, optional): Raise a KeyError if not found
- Returns:
Dimension object for the requested dimension or default
- get_dimension_index(dimension)[source]#
Get the index of the requested dimension.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Integer index of the requested dimension
- get_dimension_type(dim)[source]#
Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common type of the dimension values, otherwise None.
- Args:
dimension: Dimension to look up by name or by index
- Returns:
Declared type of values along the dimension
- groupby(dimensions=None, container_type=<class 'holoviews.core.spaces.HoloMap'>, group_type=None, dynamic=False, **kwargs)[source]#
Groups object by one or more dimensions
Applies groupby operation over the specified dimensions returning an object of type container_type (expected to be dictionary-like) containing the groups.
- Args:
dimensions: Dimension(s) to group by container_type: Type to cast group container to group_type: Type to cast each group to dynamic: Whether to return a DynamicMap **kwargs: Keyword arguments to pass to each group
- Returns:
Returns object of supplied container_type containing the groups. If dynamic=True returns a DynamicMap instead.
- hist(dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs)[source]#
Computes and adjoins histogram along specified dimension(s).
Defaults to first value dimension if present otherwise falls back to first key dimension.
- Args:
dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (tuple optional): Lower and upper bounds of bins adjoin (bool, optional): Whether to adjoin histogram
- Returns:
AdjointLayout of element and histogram or just the histogram
- property iloc#
Returns iloc indexer with support for columnar indexing.
Returns an iloc object providing a convenient interface to slice and index into the Dataset using row and column indices. Allow selection by integer index, slice and list of integer indices and boolean arrays.
Examples:
Index the first row and column:
dataset.iloc[0, 0]
Select rows 1 and 2 with a slice:
dataset.iloc[1:3, :]
Select with a list of integer coordinates:
dataset.iloc[[0, 2, 3]]
- map(map_fn, specs=None, clone=True)[source]#
Map a function to all objects matching the specs
Recursively replaces elements using a map function when the specs apply, by default applies to all objects, e.g. to apply the function to all contained Curve objects:
dmap.map(fn, hv.Curve)
- Args:
map_fn: Function to apply to each object specs: List of specs to match
List of types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
clone: Whether to clone the object or transform inplace
- Returns:
Returns the object after the map_fn has been applied
- matches(spec)[source]#
Whether the spec applies to this object.
- Args:
- spec: A function, spec or type to check for a match
A ‘type[[.group].label]’ string which is compared against the type, group and label of this object
A function which is given the object and returns a boolean.
An object type matched using isinstance.
- Returns:
bool: Whether the spec matched this object.
- property ndloc#
Returns ndloc indexer with support for gridded indexing.
Returns an ndloc object providing nd-array like indexing for gridded datasets. Follows NumPy array indexing conventions, allowing for indexing, slicing and selecting a list of indices on multi-dimensional arrays using integer indices. The order of array indices is inverted relative to the Dataset key dimensions, e.g. an Image with key dimensions ‘x’ and ‘y’ can be indexed with
image.ndloc[iy, ix]
, whereiy
andix
are integer indices along the y and x dimensions.Examples:
Index value in 2D array:
dataset.ndloc[3, 1]
Slice along y-axis of 2D array:
dataset.ndloc[2:5, :]
Vectorized (non-orthogonal) indexing along x- and y-axes:
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
- options(*args, clone=True, **kwargs)[source]#
Applies simplified option definition returning a new object.
Applies options on an object or nested group of objects in a flat format returning a new object with the options applied. If the options are to be set directly on the object a simple format may be used, e.g.:
obj.options(cmap=’viridis’, show_title=False)
If the object is nested the options must be qualified using a type[.group][.label] specification, e.g.:
obj.options(‘Image’, cmap=’viridis’, show_title=False)
or using:
obj.options({‘Image’: dict(cmap=’viridis’, show_title=False)})
Identical to the .opts method but returns a clone of the object by default.
- Args:
- *args: Sets of options to apply to object
Supports a number of formats including lists of Options objects, a type[.group][.label] followed by a set of keyword options to apply and a dictionary indexed by type[.group][.label] specs.
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, optional): Whether to clone object
Options can be applied inplace with clone=False
- **kwargs: Keywords of options
Set of options to apply to the object
- Returns:
Returns the cloned object with the options applied
- persist()[source]#
Persists the results of a lazy data interface to memory to speed up data manipulation and visualization. If the particular data backend already holds the data in memory this is a no-op. Unlike the compute method this maintains the same data type.
- Returns:
Dataset with the data persisted to memory
- property pipeline#
Chain operation that evaluates the sequence of operations that was used to create this object, starting with the Dataset stored in dataset property
- range(dim, data_range=True, dimension_range=True)[source]#
Return the lower and upper bounds of values along dimension.
- Args:
dimension: The dimension to compute the range on. data_range (bool): Compute range from data values dimension_range (bool): Include Dimension ranges
Whether to include Dimension range and soft_range in range calculation
- Returns:
Tuple containing the lower and upper bound
- reduce(dimensions=None, function=None, spreadfn=None, **reductions)[source]#
Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
ds.reduce([‘x’], np.mean)
Defining a reduction using keywords, e.g.:
ds.reduce(x=np.mean)
- Args:
- dimensions: Dimension(s) to apply reduction on
Defaults to all key dimensions
function: Reduction operation to apply, e.g. numpy.mean spreadfn: Secondary reduction to compute value spread
Useful for computing a confidence interval, spread, or standard deviation.
- **reductions: Keyword argument defining reduction
Allows reduction to be defined as keyword pair of dimension and function
- Returns:
The Dataset after reductions have been applied.
- reindex(kdims=None, vdims=None)[source]#
Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key dimensions. By default drops all non-varying key dimensions.x
- Args:
kdims (optional): New list of key dimensionsx vdims (optional): New list of value dimensions
- Returns:
Reindexed object
- relabel(label=None, group=None, depth=0)[source]#
Clone object and apply new group and/or label.
Applies relabeling to children up to the supplied depth.
- Args:
label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied
If applied to container allows applying relabeling to contained objects up to the specified depth
- Returns:
Returns relabelled object
- sample(samples=None, bounds=None, closest=True, **kwargs)[source]#
Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching the key dimensions, returning a new object containing just the selected samples. Supports multiple signatures:
Sampling with a list of coordinates, e.g.:
ds.sample([(0, 0), (0.1, 0.2), …])
Sampling a range or grid of coordinates, e.g.:
1D: ds.sample(3) 2D: ds.sample((3, 3))
Sampling by keyword, e.g.:
ds.sample(x=0)
- Args:
samples: List of nd-coordinates to sample bounds: Bounds of the region to sample
Defined as two-tuple for 1D sampling and four-tuple for 2D sampling.
closest: Whether to snap to closest coordinates **kwargs: Coordinates specified as keyword pairs
Keywords of dimensions and scalar coordinates
- Returns:
Element containing the sampled coordinates
- select(selection_expr=None, selection_specs=None, **selection)[source]#
Applies selection by dimension name
Applies a selection along the dimensions of the object using keyword arguments. The selection may be narrowed to certain objects using selection_specs. For container objects the selection will be applied to all children as well.
Selections may select a specific value, slice or set of values:
- value: Scalar values will select rows along with an exact
match, e.g.:
ds.select(x=3)
- slice: Slices may be declared as tuples of the upper and
lower bound, e.g.:
ds.select(x=(0, 3))
- values: A list of values may be selected using a list or
set, e.g.:
ds.select(x=[0, 1, 2])
predicate expression: A holoviews.dim expression, e.g.:
from holoviews import dim ds.select(selection_expr=dim(‘x’) % 2 == 0)
- Args:
- selection_expr: holoviews.dim predicate expression
specifying selection.
- selection_specs: List of specs to match on
A list of types, functions, or type[.group][.label] strings specifying which objects to apply the selection on.
- **selection: Dictionary declaring selections by dimension
Selections can be scalar values, tuple ranges, lists of discrete values and boolean arrays
- Returns:
Returns an Dimensioned object containing the selected data or a scalar if a single value was selected
- property shape#
Returns the shape of the data.
- sort(by=None, reverse=False)[source]#
Sorts the data by the values along the supplied dimensions.
- Args:
by: Dimension(s) to sort by reverse (bool, optional): Reverse sort order
- Returns:
Sorted Dataset
- property to#
Returns the conversion interface with methods to convert Dataset
- transform(*args, **kwargs)[source]#
Transforms the Dataset according to a dimension transform.
Transforms may be supplied as tuples consisting of the dimension(s) and the dim transform to apply or keyword arguments mapping from dimension(s) to dim transforms. If the arg or kwarg declares multiple dimensions the dim transform should return a tuple of values for each.
A transform may override an existing dimension or add a new one in which case it will be added as an additional value dimension.
- Args:
- args: Specify the output arguments and transforms as a
tuple of dimension specs and dim transforms
drop (bool): Whether to drop all variables not part of the transform keep_index (bool): Whether to keep indexes
Whether to apply transform on datastructure with index, e.g. pandas.Series or xarray.DataArray, (important for dask datastructures where index may be required to align datasets).
kwargs: Specify new dimensions in the form new_dim=dim_transform
- Returns:
Transformed dataset with new dimensions
- traverse(fn=None, specs=None, full_breadth=True)[source]#
Traverses object returning matching items Traverses the set of children of the object, collecting the all objects matching the defined specs. Each object can be processed with the supplied function. Args:
fn (function, optional): Function applied to matched objects specs: List of specs to match
Specs must be types, functions or type[.group][.label] specs to select objects to return, by default applies to all objects.
- full_breadth: Whether to traverse all objects
Whether to traverse the full set of objects on each container or only the first.
- Returns:
list: List of objects that matched
- class holoviews.__init__.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 0x127318fd0>)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 0x12731a5d0>)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 0x127318f10>)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 0x127319ed0>)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 0x12731a690>)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 0x12731a810>)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 0x126b5c210>)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 0x1259d8090>)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 0x127318610>)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 0x127318c50>)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
- class holoviews.__init__.dim(obj, *args, **kwargs)[source]#
Bases:
object
dim transform objects are a way to express deferred transforms on Datasets. dim transforms support all mathematical and bitwise operators, NumPy ufuncs and methods, and provide a number of useful methods for normalizing, binning and categorizing data.
- applies(dataset, strict=False)[source]#
Determines whether the dim transform can be applied to the Dataset, i.e. whether all referenced dimensions can be resolved.
- apply(dataset, flat=False, expanded=None, ranges=None, all_values=False, keep_index=False, compute=True, strict=False)[source]#
Evaluates the transform on the supplied dataset.
- Args:
dataset: Dataset object to evaluate the expression on flat: Whether to flatten the returned array expanded: Whether to use the expanded expand values ranges: Dictionary for ranges for normalization all_values: Whether to evaluate on all values
Whether to evaluate on all available values, for some element types, such as Graphs, this may include values not included in the referenced column
- keep_index: For data types that support indexes, whether the index
should be preserved in the result.
- compute: For data types that support lazy evaluation, whether
the result should be computed before it is returned.
- strict: Whether to strictly check for dimension matches
(if False, counts any dimensions with matching names as the same)
- Returns:
values: NumPy array computed by evaluating the expression
- bin(bins, labels=None)[source]#
Bins continuous values.
Bins continuous using the provided bins and assigns labels either computed from each bins center point or from the supplied labels.
- Args:
bins: List or array containing the bin boundaries labels: List of labels to assign to each bin
If the bins are length N the labels should be length N-1
- categorize(categories, default=None)[source]#
Replaces discrete values with supplied categories
Replaces discrete values in input array into a fixed set of categories defined either as a list or dictionary.
- Args:
categories: List or dict of categories to map inputs to default: Default value to assign if value not in categories
- clone(dimension=None, ops=None, dim_type=None)[source]#
Creates a clone of the dim expression optionally overriding the dim and ops.
- lognorm(limits=None)[source]#
- Unity-based normalization log scale.
Apply the same transformation as matplotlib.colors.LogNorm
- Args:
limits: tuple of (min, max) defining the normalization range
- norm(limits=None)[source]#
Unity-based normalization to scale data into 0-1 range.
(values - min) / (max - min)
- Args:
limits: tuple of (min, max) defining the normalization range
- classmethod pipe(func, *args, **kwargs)[source]#
Wrapper to give multidimensional transforms a more intuitive syntax. For a custom function ‘func’ with signature (*args, **kwargs), call as dim.pipe(func, *args, **kwargs).
- classmethod register(key, function)[source]#
Register a custom dim transform function which can from then on be referenced by the key.
- property str#
Casts values to strings or provides str accessor.
- class holoviews.__init__.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.
- holoviews.__init__.help(obj, visualization=True, ansi=True, backend=None, recursive=False, pattern=None)[source]#
Extended version of the built-in help that supports parameterized functions and objects. A pattern (regular expression) may be used to filter the output and if recursive is set to True, documentation for the supplied object is shown. Note that the recursive option will only work with an object instance and not a class.
If ansi is set to False, all ANSI color codes are stripped out.
- class holoviews.__init__.link_selections(*, cross_filter_mode, index_cols, selected_color, selection_expr, selection_mode, unselected_alpha, unselected_color, link_inputs, show_regions, name)[source]#
Bases:
_base_link_selections
Operation which automatically links selections between elements in the supplied HoloViews object. Can be used a single time or be used as an instance to apply the linked selections across multiple objects.
Parameters inherited from:
holoviews.selection._base_link_selections
: link_inputs, show_regionscross_filter_mode
= param.Selector(allow_refs=False, default=’intersect’, label=’Cross filter mode’, names={}, nested_refs=False, objects=[‘overwrite’, ‘intersect’], rx=<param.reactive.reactive_ops object at 0x12741fb90>)Determines how to combine selections across different elements.
index_cols
= param.List(allow_None=True, allow_refs=False, bounds=(0, None), label=’Index cols’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12743e7d0>)If provided, selection switches to index mode where all queries are expressed solely in terms of discrete values along the index_cols. All Elements given to link_selections must define the index_cols, either as explicit dimensions or by sharing an underlying Dataset that defines them.
selection_expr
= param.Parameter(allow_None=True, allow_refs=False, label=’Selection expr’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12741d0d0>)dim expression of the current selection or None to indicate that everything is selected.
selected_color
= param.Color(allow_None=True, allow_named=True, allow_refs=False, label=’Selected color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1267aa510>)Color of selected data, or None to use the original color of each element.
selection_mode
= param.Selector(allow_refs=False, default=’overwrite’, label=’Selection mode’, names={}, nested_refs=False, objects=[‘overwrite’, ‘intersect’, ‘union’, ‘inverse’], rx=<param.reactive.reactive_ops object at 0x12741cd10>)Determines how to combine successive selections on the same element.
unselected_alpha
= param.Magnitude(allow_refs=False, bounds=(0.0, 1.0), default=0.1, inclusive_bounds=(True, True), label=’Unselected alpha’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12741ed10>)Alpha of unselected data.
unselected_color
= param.Color(allow_None=True, allow_named=True, allow_refs=False, label=’Unselected color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x12741d0d0>)Color of unselected data.
- filter(data, selection_expr=None)[source]#
Filters the provided data based on the current state of the current selection expression.
- Args:
data: A Dataset type or data which can be cast to a Dataset selection_expr: Optionally provide your own selection expression
- Returns:
The filtered data
- instance(**params)[source]#
Return an instance of this class, copying parameters from any existing instance provided.
- property selected_cmap#
The datashader colormap for selected data
- selection_param(data)[source]#
Returns a parameter which reflects the current selection when applied to the supplied data, making it easy to create a callback which depends on the current selection.
- Args:
data: A Dataset type or data which can be cast to a Dataset
- Returns:
A parameter which reflects the current selection
- property unselected_cmap#
The datashader colormap for unselected data
- class holoviews.__init__.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.
strict
= param.Boolean(allow_refs=False, default=False, label=’Strict’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x127408450>)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.
- Args:
- options (dict): Options specification
Options specification should be indexed by type[.group][.label] or option type (‘plot’, ‘style’, ‘norm’).
- backend (optional): Backend to apply options to
Defaults to current selected backend
- clone (bool, 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.__init__.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
- holoviews.__init__.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.
Arguments#
- obj: HoloViews object
The HoloViews object to render
- backend: string
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.__init__.renderer(name)[source]#
Helper utility to access the active renderer for a given extension.
- holoviews.__init__.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’.
Arguments#
- obj: HoloViews object
The HoloViews object to save to file
- filename: string or IO object
The filename or BytesIO/StringIO object to save to
- fmt: string
The format to save the object as, e.g. png, svg, html, or gif and if widgets are desired either ‘widgets’ or ‘scrubber’
- backend: string
A valid HoloViews rendering backend, e.g. bokeh or matplotlib
- resources: string 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.
- toolbar: bool 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.
- title: string
Custom title for exported HTML file
- **kwargs: dict
Additional keyword arguments passed to the renderer, e.g. fps for animations