Plotting Grouped Series¶
Here there are the classes that plot grouped series
-
class
plotszoo.series.grouped.
GroupedSeriesParade
(data, groups, target)¶ Plot grouped mean series and their confidence intervals. Useful when working with stochastic processes. This plot requires both scalars and series and requires aligned series
- Args:
- data
plotszoo.data.DataCollection
with some series- groups
A list of scalar indices to group by
- target
The series index to plot to
Example:
import numpy as np import pandas as pd import os import matplotlib.pyplot as plt import plotszoo np.random.seed(0) num_series = 10 samples = 100 noise_level = 0.8 x = np.linspace(0, np.pi*2, samples) types = [] series = {} for _ in range(0, num_series): noisy_sin = np.sin(x) + np.random.rand(samples)*noise_level series[len(types)] = pd.DataFrame(noisy_sin, columns=["value"]) types.append("sin") noisy_cos = np.cos(x) + np.random.rand(samples)*noise_level series[len(types)] = pd.DataFrame(noisy_cos, columns=["value"]) types.append("cos") data = plotszoo.data.DataCollection() data.set_scalars(pd.DataFrame(types, columns=["type"])) data.set_series(series) fig, ax = plt.subplots() series_parade = plotszoo.series.grouped.GroupedSeriesParade(data, ["type"], "value") series_parade.plot(ax) ax.legend(loc="lower right") fig.savefig(os.path.join(os.path.dirname(os.path.realpath(__file__)), "images/GroupedSeriesParade.png"))
-
plot
(ax, cmap='tab10', normalize_color=False, alpha=0.5, goal=None, goal_type='max')¶ Plot the grouped series parade
- Args:
- ax
matplotlib
axes to plot to- cmap
matplotlib
colormap to use (Default:tab10
)- normalize_color
Call
matplotlib
before using colormap (Default:False
)- alpha
Alpha for the confidence intervals area
- goal
Stop plotting after a certain goal is reached for each series (Default
None
)- goal_type
The goal type (
max
ormin
)