plots#
This module provides tools for generating interactive plots.
Visualizations require data from a pandas.DataFrame
, or pandas.Series
.
Functions#
plot_time_series
: Plot a time series with optional colormap for data points.
Notes
The core functionality of this module is to assist with visualizing data in an interactive time series format, especially useful when you have a sequence of data points indexed in time order. The colormap feature allows users to provide a visual representation based on another data series.
- wip.datatools.plots.plot_time_series(series: pd.Series, colormap_series: pd.Series | None = None, **plot_kwargs)[source]#
Plot a time series using Plotly with optional colormap for data points.
Given a pandas series with datetime index, this function creates a Plotly interactive time series plot. Optionally, users can also provide a colormap series that determines the color of each data point in the time series plot.
- Parameters
series (
pd.Series
) – Apandas.Series
object with aDatetimeIndex
and values to plot.colormap_series (
pd.Series
, optional) – Apandas.Series
object with the same DatetimeIndex asseries
that determines the colors of each data point in the main series plot.plot_kwargs (
dict
) –Additional keyword arguments for customizing the plot appearance. Some of the recognized keys include:
width: width of the plot in pixels. Default is 1400.
height: height of the plot in pixels. Default is 700.
title: title of the plot. Default is the name of the series.
connectgaps: whether to connect data points with line. Default is True.
mode: mode of the plot. Default is “lines+markers”.
marker: a dictionary of marker properties.
- Raises
If
series
is not apandas.Series
object.If
series
index is not aDatetimeIndex
.
See also
plotly.subplots.make_subplots
,plotly.graph_objects.Scatter
,pandas.Series
Examples
>>> data = pd.Series([1, 2, 3], index=pd.date_range('2023-01-01', periods=3)) >>> colormap = pd.Series([10, 20, 30], index=pd.date_range('2023-01-01', periods=3)) >>> plot_time_series(data, colormap_series=colormap)
Or:
>>> plot_time_series(data)