plotting moduleΒΆ
Base plotting functions.
Provides functions for visualizing data in an efficient and convenient way. Each creates a figure widget that is compatible with ipywidgets and enables interactive data visualization in Jupyter Notebook and JupyterLab environments. For more details on using Plotly, see Getting Started with Plotly in Python.
The module can be accessed directly via vbt.plotting.
Warning
In case of errors, it won't be visible in the notebook cell, but in the logs.
clean_labels functionΒΆ
clean_labels(
labels
)
Clean labels.
Plotly doesn't support multi-indexes.
Bar classΒΆ
Bar(
data=None,
trace_names=None,
x_labels=None,
trace_kwargs=None,
add_trace_kwargs=None,
fig=None,
**layout_kwargs
)
Class with an initialization config.
All subclasses of Configured are initialized using Config, which makes it easier to pickle.
Settings are defined under configured in settings.
Warning
If any attribute has been overwritten that isn't listed in Configured.writeable_attrs, or if any Configured.__init__ argument depends upon global defaults, their values won't be copied over. Make sure to pass them explicitly to make the saved & loaded / copied instance resilient to changes in globals.
Create a bar plot.
Args
data:βarray_like-
Data in any format that can be converted to NumPy.
Must be of shape (
x_labels,trace_names). trace_names:βstrorlistofstr- Trace names, corresponding to columns in pandas.
x_labels:βarray_like- X-axis labels, corresponding to index in pandas.
trace_kwargs:βdictorlistofdict-
Keyword arguments passed to
plotly.graph_objects.Bar.Can be specified per trace as a sequence of dicts.
add_trace_kwargs:βdict- Keyword arguments passed to
add_trace. fig:βFigureorFigureWidget- Figure to add traces to.
**layout_kwargs- Keyword arguments for layout.
Usage
>>> import vectorbt as vbt
>>> bar = vbt.plotting.Bar(
... data=[[1, 2], [3, 4]],
... trace_names=['a', 'b'],
... x_labels=['x', 'y']
... )
>>> bar.fig
Superclasses
Inherited members
- Configured.config
- Configured.copy()
- Configured.dumps()
- Configured.loads()
- Configured.replace()
- Configured.to_doc()
- Configured.update_config()
- Configured.writeable_attrs
- Pickleable.load()
- Pickleable.save()
- TraceUpdater.fig
- TraceUpdater.traces
update methodΒΆ
Bar.update(
data
)
Update the trace data.
Usage
>>> bar.update([[2, 1], [4, 3]])
>>> bar.fig
Box classΒΆ
Box(
data=None,
trace_names=None,
horizontal=False,
remove_nan=True,
from_quantile=None,
to_quantile=None,
trace_kwargs=None,
add_trace_kwargs=None,
fig=None,
**layout_kwargs
)
Class with an initialization config.
All subclasses of Configured are initialized using Config, which makes it easier to pickle.
Settings are defined under configured in settings.
Warning
If any attribute has been overwritten that isn't listed in Configured.writeable_attrs, or if any Configured.__init__ argument depends upon global defaults, their values won't be copied over. Make sure to pass them explicitly to make the saved & loaded / copied instance resilient to changes in globals.
Create a box plot.
For keyword arguments, see Histogram.
Usage
>>> import vectorbt as vbt
>>> box = vbt.plotting.Box(
... data=[[1, 2], [3, 4], [2, 1]],
... trace_names=['a', 'b']
... )
>>> box.fig
Superclasses
Inherited members
- Configured.config
- Configured.copy()
- Configured.dumps()
- Configured.loads()
- Configured.replace()
- Configured.to_doc()
- Configured.update_config()
- Configured.writeable_attrs
- Pickleable.load()
- Pickleable.save()
- TraceUpdater.fig
- TraceUpdater.traces
- TraceUpdater.update()
from_quantile propertyΒΆ
Filter out data points before this quantile.
horizontal propertyΒΆ
Whether to plot horizontally.
remove_nan propertyΒΆ
Whether to remove NaN values.
to_quantile propertyΒΆ
Filter out data points after this quantile.
Gauge classΒΆ
Gauge(
value=None,
label=None,
value_range=None,
cmap_name='Spectral',
trace_kwargs=None,
add_trace_kwargs=None,
fig=None,
**layout_kwargs
)
Class with an initialization config.
All subclasses of Configured are initialized using Config, which makes it easier to pickle.
Settings are defined under configured in settings.
Warning
If any attribute has been overwritten that isn't listed in Configured.writeable_attrs, or if any Configured.__init__ argument depends upon global defaults, their values won't be copied over. Make sure to pass them explicitly to make the saved & loaded / copied instance resilient to changes in globals.
Create a gauge plot.
Args
value:βfloat- The value to be displayed.
label:βstr- The label to be displayed.
value_range:βtupleoffloat- The value range of the gauge.
cmap_name:βstr-
A matplotlib-compatible colormap name.
See the list of available colormaps.
trace_kwargs:βdict- Keyword arguments passed to the
plotly.graph_objects.Indicator. add_trace_kwargs:βdict- Keyword arguments passed to
add_trace. fig:βFigureorFigureWidget- Figure to add traces to.
**layout_kwargs- Keyword arguments for layout.
Usage
>>> import vectorbt as vbt
>>> gauge = vbt.plotting.Gauge(
... value=2,
... value_range=(1, 3),
... label='My Gauge'
... )
>>> gauge.fig
Superclasses
Inherited members
- Configured.config
- Configured.copy()
- Configured.dumps()
- Configured.loads()
- Configured.replace()
- Configured.to_doc()
- Configured.update_config()
- Configured.writeable_attrs
- Pickleable.load()
- Pickleable.save()
- TraceUpdater.fig
- TraceUpdater.traces
- TraceUpdater.update()
cmap_name propertyΒΆ
A matplotlib-compatible colormap name.
value_range propertyΒΆ
The value range of the gauge.
Heatmap classΒΆ
Heatmap(
data=None,
x_labels=None,
y_labels=None,
is_x_category=False,
is_y_category=False,
trace_kwargs=None,
add_trace_kwargs=None,
fig=None,
**layout_kwargs
)
Class with an initialization config.
All subclasses of Configured are initialized using Config, which makes it easier to pickle.
Settings are defined under configured in settings.
Warning
If any attribute has been overwritten that isn't listed in Configured.writeable_attrs, or if any Configured.__init__ argument depends upon global defaults, their values won't be copied over. Make sure to pass them explicitly to make the saved & loaded / copied instance resilient to changes in globals.
Create a heatmap plot.
Args
data:βarray_like-
Data in any format that can be converted to NumPy.
Must be of shape (
y_labels,x_labels). x_labels:βarray_like- X-axis labels, corresponding to columns in pandas.
y_labels:βarray_like- Y-axis labels, corresponding to index in pandas.
is_x_category:βbool- Whether X-axis is a categorical axis.
is_y_category:βbool- Whether Y-axis is a categorical axis.
trace_kwargs:βdict- Keyword arguments passed to
plotly.graph_objects.Heatmap. add_trace_kwargs:βdict- Keyword arguments passed to
add_trace. fig:βFigureorFigureWidget- Figure to add traces to.
**layout_kwargs- Keyword arguments for layout.
Usage
>>> import vectorbt as vbt
>>> heatmap = vbt.plotting.Heatmap(
... data=[[1, 2], [3, 4]],
... x_labels=['a', 'b'],
... y_labels=['x', 'y']
... )
>>> heatmap.fig
Superclasses
Inherited members
- Configured.config
- Configured.copy()
- Configured.dumps()
- Configured.loads()
- Configured.replace()
- Configured.to_doc()
- Configured.update_config()
- Configured.writeable_attrs
- Pickleable.load()
- Pickleable.save()
- TraceUpdater.fig
- TraceUpdater.traces
- TraceUpdater.update()
Histogram classΒΆ
Histogram(
data=None,
trace_names=None,
horizontal=False,
remove_nan=True,
from_quantile=None,
to_quantile=None,
trace_kwargs=None,
add_trace_kwargs=None,
fig=None,
**layout_kwargs
)
Class with an initialization config.
All subclasses of Configured are initialized using Config, which makes it easier to pickle.
Settings are defined under configured in settings.
Warning
If any attribute has been overwritten that isn't listed in Configured.writeable_attrs, or if any Configured.__init__ argument depends upon global defaults, their values won't be copied over. Make sure to pass them explicitly to make the saved & loaded / copied instance resilient to changes in globals.
Create a histogram plot.
Args
data:βarray_like-
Data in any format that can be converted to NumPy.
Must be of shape (any,
trace_names). trace_names:βstrorlistofstr- Trace names, corresponding to columns in pandas.
horizontal:βbool- Whether to plot horizontally.
remove_nan:βbool- Whether to remove NaN values.
from_quantile:βfloat-
Filter out data points before this quantile.
Should be in range
[0, 1]. to_quantile:βfloat-
Filter out data points after this quantile.
Should be in range
[0, 1]. trace_kwargs:βdictorlistofdict-
Keyword arguments passed to
plotly.graph_objects.Histogram.Can be specified per trace as a sequence of dicts.
add_trace_kwargs:βdict- Keyword arguments passed to
add_trace. fig:βFigureorFigureWidget- Figure to add traces to.
**layout_kwargs- Keyword arguments for layout.
Usage
>>> import vectorbt as vbt
>>> hist = vbt.plotting.Histogram(
... data=[[1, 2], [3, 4], [2, 1]],
... trace_names=['a', 'b']
... )
>>> hist.fig
Superclasses
Inherited members
- Configured.config
- Configured.copy()
- Configured.dumps()
- Configured.loads()
- Configured.replace()
- Configured.to_doc()
- Configured.update_config()
- Configured.writeable_attrs
- Pickleable.load()
- Pickleable.save()
- TraceUpdater.fig
- TraceUpdater.traces
- TraceUpdater.update()
from_quantile propertyΒΆ
Filter out data points before this quantile.
horizontal propertyΒΆ
Whether to plot horizontally.
remove_nan propertyΒΆ
Whether to remove NaN values.
to_quantile propertyΒΆ
Filter out data points after this quantile.
Scatter classΒΆ
Scatter(
data=None,
trace_names=None,
x_labels=None,
trace_kwargs=None,
add_trace_kwargs=None,
fig=None,
**layout_kwargs
)
Class with an initialization config.
All subclasses of Configured are initialized using Config, which makes it easier to pickle.
Settings are defined under configured in settings.
Warning
If any attribute has been overwritten that isn't listed in Configured.writeable_attrs, or if any Configured.__init__ argument depends upon global defaults, their values won't be copied over. Make sure to pass them explicitly to make the saved & loaded / copied instance resilient to changes in globals.
Create a scatter plot.
Args
data:βarray_like-
Data in any format that can be converted to NumPy.
Must be of shape (
x_labels,trace_names). trace_names:βstrorlistofstr- Trace names, corresponding to columns in pandas.
x_labels:βarray_like- X-axis labels, corresponding to index in pandas.
trace_kwargs:βdictorlistofdict-
Keyword arguments passed to
plotly.graph_objects.Scatter.Can be specified per trace as a sequence of dicts.
add_trace_kwargs:βdict- Keyword arguments passed to
add_trace. fig:βFigureorFigureWidget- Figure to add traces to.
**layout_kwargs- Keyword arguments for layout.
Usage
>>> import vectorbt as vbt
>>> scatter = vbt.plotting.Scatter(
... data=[[1, 2], [3, 4]],
... trace_names=['a', 'b'],
... x_labels=['x', 'y']
... )
>>> scatter.fig
Superclasses
Inherited members
- Configured.config
- Configured.copy()
- Configured.dumps()
- Configured.loads()
- Configured.replace()
- Configured.to_doc()
- Configured.update_config()
- Configured.writeable_attrs
- Pickleable.load()
- Pickleable.save()
- TraceUpdater.fig
- TraceUpdater.traces
- TraceUpdater.update()
TraceUpdater classΒΆ
TraceUpdater(
fig,
traces
)
Base trace updating class.
Subclasses
fig propertyΒΆ
Figure.
traces propertyΒΆ
Traces to update.
update methodΒΆ
TraceUpdater.update(
*args,
**kwargs
)
Update the trace data.
Volume classΒΆ
Volume(
data=None,
x_labels=None,
y_labels=None,
z_labels=None,
trace_kwargs=None,
add_trace_kwargs=None,
scene_name='scene',
fig=None,
**layout_kwargs
)
Class with an initialization config.
All subclasses of Configured are initialized using Config, which makes it easier to pickle.
Settings are defined under configured in settings.
Warning
If any attribute has been overwritten that isn't listed in Configured.writeable_attrs, or if any Configured.__init__ argument depends upon global defaults, their values won't be copied over. Make sure to pass them explicitly to make the saved & loaded / copied instance resilient to changes in globals.
Create a volume plot.
Args
data:βarray_like-
Data in any format that can be converted to NumPy.
Must be a 3-dim array.
x_labels:βarray_like- X-axis labels.
y_labels:βarray_like- Y-axis labels.
z_labels:βarray_like- Z-axis labels.
trace_kwargs:βdict- Keyword arguments passed to
plotly.graph_objects.Volume. add_trace_kwargs:βdict- Keyword arguments passed to
add_trace. scene_name:βstr- Reference to the 3D scene.
fig:βFigureorFigureWidget- Figure to add traces to.
**layout_kwargs- Keyword arguments for layout.
Note
Figure widgets have currently problems displaying NaNs. Use .show() method for rendering.
Usage
>>> import vectorbt as vbt
>>> import numpy as np
>>> volume = vbt.plotting.Volume(
... data=np.random.randint(1, 10, size=(3, 3, 3)),
... x_labels=['a', 'b', 'c'],
... y_labels=['d', 'e', 'f'],
... z_labels=['g', 'h', 'i']
... )
>>> volume.fig
Superclasses
Inherited members