plotter
frequenz.lib.notebooks.reporting.plotter ¤
Plotting functions for the reporting module.
Functions¤
frequenz.lib.notebooks.reporting.plotter.plot_energy_pie_chart ¤
Create an interactive donut (pie) chart of energy sources.
Generates a pie chart showing the relative energy contributions from different sources (e.g., PV, grid, CHP), with percentage labels and hover details in kilowatt-hours.
| PARAMETER | DESCRIPTION |
|---|---|
power_df
|
DataFrame containing at least two columns:
-
TYPE:
|
color_dict
|
Optional dictionary mapping energy sources (Energiebezug) to custom color hex codes or rgba strings. If not provided, Plotly's default color sequence is used. |
| RETURNS | DESCRIPTION |
|---|---|
Figure
|
A Plotly Figure object representing a donut-style energy distribution chart. |
Source code in frequenz/lib/notebooks/reporting/plotter.py
frequenz.lib.notebooks.reporting.plotter.plot_time_series ¤
plot_time_series(
df: DataFrame,
time_col: str | None = None,
cols: list[str] | None = None,
title: str = "Time Series Plot",
xaxis_title: str = "Timestamp",
yaxis_title: str = "kW",
legend_title: str = "Components",
color_dict: dict[str, str] | None = None,
long_format_flag: bool = False,
category_col: str | None = None,
value_col: str | None = None,
fill_cols: list[str] | None = None,
plot_order: list[str] | None = None,
) -> Figure
Create an interactive time-series plot using Plotly.
Generates a multi-line time-series plot from a DataFrame, optionally handling long-to-wide data transformations and area fills for selected columns. The plot includes zoom controls, a range slider, and a date range selector.
| PARAMETER | DESCRIPTION |
|---|---|
df
|
Input DataFrame containing time and numeric data.
TYPE:
|
time_col
|
Name of the timestamp column to use as the x-axis. If None, the current index is used.
TYPE:
|
cols
|
List of numeric columns to plot. If None, all numeric columns
except |
title
|
Plot title displayed at the top. Defaults to "Time Series Plot".
TYPE:
|
xaxis_title
|
Label for the x-axis. Defaults to "Timestamp".
TYPE:
|
yaxis_title
|
Label for the y-axis. Defaults to "kW".
TYPE:
|
legend_title
|
Title for the legend. Defaults to "Components".
TYPE:
|
color_dict
|
Optional dictionary mapping column names to custom colors. If not provided, default Plotly colors are used. |
long_format_flag
|
Whether to convert the DataFrame from long to wide format before plotting. Defaults to False.
TYPE:
|
category_col
|
Column name for categories when converting from long to
wide format. Used only if
TYPE:
|
value_col
|
Column name for values when converting from long to wide
format. Used only if
TYPE:
|
fill_cols
|
List of column names to plot as filled areas under the curve. Defaults to None (no fill). |
plot_order
|
Optional list specifying the order of columns to plot. If None,
the order in |
| RETURNS | DESCRIPTION |
|---|---|
Figure
|
A Plotly Figure object representing the interactive time-series plot. |
| RAISES | DESCRIPTION |
|---|---|
KeyError
|
If |
Source code in frequenz/lib/notebooks/reporting/plotter.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |