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 = "",
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,
secondary_y_cols: Sequence[str] | None = None,
secondary_y_title: 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). |
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:
|
secondary_y_cols
|
Optional plotted columns to render on a secondary y-axis. |
secondary_y_title
|
Optional title for the secondary y-axis. Defaults to
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
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 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 | |
frequenz.lib.notebooks.reporting.plotter.plot_time_series_battery_usecase ¤
plot_time_series_battery_usecase(
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,
battery_power_flow: str = "battery_power_flow",
battery_charging: str = "battery_discharge",
battery_discharging: str = "battery_charge",
pv_col: str = "pv",
consumption_col: str = "consumption",
grid_consumption: str = "grid_consumption",
stack_mode: BatteryUsecaseStackMode = "psc",
secondary_y_cols: Sequence[str] | None = None,
secondary_y_title: str | None = None,
) -> Figure
Plot a battery-usecase time series with charge/discharge overlays.
Builds a reporting plot for battery-usecase analysis by combining the standard time-series traces with dedicated filled overlays for battery charging and discharging with selectable legacy/current stacking.
| PARAMETER | DESCRIPTION |
|---|---|
df
|
Source DataFrame containing the battery-usecase time series.
TYPE:
|
time_col
|
Optional timestamp column to use as the x-axis.
TYPE:
|
cols
|
Optional columns to plot. |
title
|
Plot title.
TYPE:
|
xaxis_title
|
X-axis label.
TYPE:
|
yaxis_title
|
Primary y-axis label.
TYPE:
|
legend_title
|
Legend title.
TYPE:
|
color_dict
|
Optional color mapping for traces. |
long_format_flag
|
Whether
TYPE:
|
category_col
|
Category column name for long-format inputs.
TYPE:
|
value_col
|
Value column name for long-format inputs.
TYPE:
|
fill_cols
|
Columns to render as filled traces. |
dotted_cols
|
Columns to render with dotted lines. |
plot_order
|
Optional explicit trace order. |
shade_by_category
|
Whether to generate color shades by category.
TYPE:
|
battery_power_flow
|
Column containing battery power flow values.
TYPE:
|
battery_charging
|
Column containing the battery charging series.
TYPE:
|
battery_discharging
|
Column containing the battery discharging series.
TYPE:
|
pv_col
|
Column containing PV production values.
TYPE:
|
consumption_col
|
Column containing site consumption.
TYPE:
|
grid_consumption
|
Column containing grid consumption with battery support.
TYPE:
|
stack_mode
|
Overlay style selector.
TYPE:
|
secondary_y_cols
|
Optional columns to render on the secondary y-axis. |
secondary_y_title
|
Secondary y-axis label.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Figure
|
A Plotly figure for battery-usecase analysis. |
Source code in src/frequenz/lib/notebooks/reporting/plotter.py
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 | |