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 src/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 | None = "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,
dotted_cols: list[str] | None = None,
plot_order: list[str] | None = None,
shade_by_category: bool = False,
) -> 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). |
dotted_cols
|
List of column names to render with dotted lines. Defaults to None (no dotted lines). |
plot_order
|
Optional list specifying the order of columns to plot. If None,
the order in |
shade_by_category
|
When plotting a long-format series, render all categories as different shades of the same base color.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Figure
|
A Plotly Figure object representing the interactive time-series plot. |
| RAISES | DESCRIPTION |
|---|---|
KeyError
|
If |
Source code in src/frequenz/lib/notebooks/reporting/plotter.py
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 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | |