Plotting¶
Requires either matplotlib or plotly to be installed, e.g. via
pip install "tirex-2[examples]".
tirex2.plotting.plot_multivariate ¶
plot_multivariate(input: TimeseriesType, forecast: Tensor | ndarray, ground_truth: Tensor | ndarray | None = None, x: Sequence | None = None, quantiles: tuple[float, float] = (0.1, 0.9), quantile_levels: tuple[float] = (0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9), max_context_to_show: int | None = None, target_index: int = 0, past_cov_labels: list[str] | None = None, future_cov_labels: list[str] | None = None, engine='plotly', title: str | None = None, subtitle: str | None = None)
Source code in src/tirex2/plotting.py
705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 | |
tirex2.plotting.plot_forecast ¶
plot_forecast(context: Tensor | ndarray | None = None, forecasts: Tensor | ndarray | None = None, ground_truth: Tensor | ndarray | None = None, x: Sequence | None = None, quantiles: tuple[float, float] = (0.1, 0.9), quantile_levels: tuple[float] = (0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9), engine='plotly', max_context_to_show: int | None = None, ax=None, fig=None, **kwargs)
Plots the historical context, optional ground-truth future, and forecast.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
Tensor or ndarray
|
The historical time series data to be plotted. |
None
|
forecasts
|
Tensor or ndarray
|
The forecasts data including quantiles, of shape [Q, N], where Q=9 quantiles are required, and N is the number of forecast timesteps. |
None
|
ground_truth
|
Tensor or ndarray
|
The actual future data to compare the forecast against. |
None
|
x
|
Sequence
|
X-axis values (e.g., timestamps or indices) for the data. The sequence must be slicable. |
None
|
quantiles
|
tuple[float]
|
A tuple indicating the quantile levels to use to plot as shaded areas around the median forecast. Set to None to deactivate. Default is (0.1, 0.9). |
(0.1, 0.9)
|
quantile_levels
|
tuple[float]
|
A tuple indicating the quantile levels. |
(0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9)
|
engine
|
str
|
What framework to use for rendering the plots. |
'plotly'
|
max_context_to_show
|
int
|
If set, limits the number of context points to show for better visibility of forecasts. |
None
|
ax
|
Axes or Figure
|
The matplotlib axes / plotly figure object to plot on. |
None
|
**kwargs
|
Additional keyword arguments to pass to the plotting functions. |
{}
|
Returns:
| Type | Description |
|---|---|
Axes
|
The Axes object with the plotted forecast, if engine="matplotlib" |
Figure
|
The Figure object with the plotted forecast, if engine="plotly" |
Source code in src/tirex2/plotting.py
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 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | |
tirex2.plotting.plot_covariate ¶
plot_covariate(covariate: Tensor | ndarray | None, label: str | None = None, color: str = COVARIATE_COLORS[0], x: Sequence | None = None, engine='plotly', ax=None, fig=None, **kwargs)
Source code in src/tirex2/plotting.py
529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 | |