API Reference¶
This is the API reference for MONET Plots.
Modules¶
Cartopy-based plotting utilities for MONET.
facet_time_map(da, time_dim='time', ncols=3, map_kws=None, projection=None, colorbar=True, figsize=None, cmap=None, vmin=None, vmax=None, norm=None, dpi=150, xlabel=None, ylabel=None, suptitle=None, cbar_label=None, xticks=None, yticks=None, annotations=None, export_path=None, export_formats=None, **kwargs)
¶
Create a facet grid of map plots for each time slice in a DataArray using Cartopy.
Parameters¶
da : xarray.DataArray The data to plot (must have a time dimension). time_dim : str, default: "time" Name of the time dimension. ncols : int, default: 3 Number of columns in the facet grid. map_kws : dict, optional Dictionary of keyword arguments for map features. projection : cartopy.crs.Projection, optional Cartopy projection to use. Defaults to PlateCarree. colorbar : bool, default: True Whether to add a colorbar (shared). figsize : tuple, optional Figure size. cmap : str or Colormap, optional Colormap to use. vmin, vmax : float, optional Color limits. norm : Normalize, optional Matplotlib normalization. dpi : int, optional Dots per inch for export. xlabel, ylabel, suptitle : str, optional Axis labels and super title. cbar_label : str, optional Label for the colorbar. xticks, yticks : list, optional Custom tick locations. annotations : list of dict, optional List of annotation dicts for each subplot. export_path : str, optional Path to export the figure (without extension). export_formats : list, optional List of formats to export (e.g., ["png", "pdf"]). **kwargs : dict Additional keyword arguments for plotting.
Returns¶
fig : matplotlib.figure.Figure The matplotlib figure object. axes : ndarray of matplotlib.axes.Axes The matplotlib axes objects.
Source code in src/monet_plots/cartopy_utils.py
520 521 522 523 524 525 526 527 528 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 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 | |
plot_lines_map(df, lon_col='longitude', lat_col='latitude', group_col=None, projection=None, color='C0', linewidth=2, alpha=0.8, map_kws=None, figsize=(8, 6), dpi=150, title=None, export_path=None, export_formats=None, **kwargs)
¶
Plot lines from a DataFrame on a Cartopy map. Optionally group by a column.
Parameters¶
df : pandas.DataFrame DataFrame with longitude and latitude columns. lon_col, lat_col : str Column names for longitude and latitude. group_col : str, optional Column to group lines (e.g., for trajectories). projection : cartopy.crs.Projection, optional Cartopy projection to use. Defaults to PlateCarree. color : str or array-like, optional Line color. linewidth : float, optional Line width. alpha : float, optional Line transparency. map_kws : dict, optional Map feature keyword arguments. figsize : tuple, optional Figure size. dpi : int, optional Dots per inch for export. title : str, optional Plot title. export_path : str, optional Path to export the figure (without extension). export_formats : list, optional List of formats to export (e.g., ["png", "pdf"]). **kwargs : dict Additional keyword arguments for plt.plot.
Returns¶
fig, ax : matplotlib Figure and Axes
Source code in src/monet_plots/cartopy_utils.py
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 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 | |
plot_points_map(df, lon_col='longitude', lat_col='latitude', projection=None, color='C0', marker='o', size=40, edgecolor='k', alpha=0.8, map_kws=None, figsize=(8, 6), dpi=150, title=None, export_path=None, export_formats=None, **kwargs)
¶
Plot points from a DataFrame on a Cartopy map.
Parameters¶
df : pandas.DataFrame DataFrame with longitude and latitude columns. lon_col, lat_col : str Column names for longitude and latitude. projection : cartopy.crs.Projection, optional Cartopy projection to use. Defaults to PlateCarree. color : str or array-like, optional Color for points. marker : str, optional Marker style. size : float or array-like, optional Marker size. edgecolor : str, optional Marker edge color. alpha : float, optional Marker transparency. map_kws : dict, optional Map feature keyword arguments. figsize : tuple, optional Figure size. dpi : int, optional Dots per inch for export. title : str, optional Plot title. export_path : str, optional Path to export the figure (without extension). export_formats : list, optional List of formats to export (e.g., ["png", "pdf"]). **kwargs : dict Additional keyword arguments for plt.scatter.
Returns¶
fig, ax : matplotlib Figure and Axes
Source code in src/monet_plots/cartopy_utils.py
639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 | |
plot_quick_contourf(da, map_kws=None, projection=None, colorbar=True, figsize=None, cmap=None, vmin=None, vmax=None, norm=None, dpi=150, xlabel=None, ylabel=None, title=None, cbar_label=None, cbar_inset=False, xticks=None, yticks=None, annotations=None, export_path=None, export_formats=None, **kwargs)
¶
Create a publication-quality filled contour plot of the data on a map using Cartopy.
Parameters¶
da : xarray.DataArray The data to plot. map_kws : dict, optional Dictionary of keyword arguments for map features (e.g., coastlines, gridlines, features, borders, land, ocean). projection : cartopy.crs.Projection, optional Cartopy projection to use. Defaults to PlateCarree. colorbar : bool, default: True Whether to add a colorbar. figsize : tuple, optional Figure size. cmap : str or Colormap, optional Colormap to use (supports colorblind-friendly options). vmin, vmax : float, optional Color limits. norm : Normalize, optional Matplotlib normalization (e.g., LogNorm). dpi : int, optional Dots per inch for export. xlabel, ylabel, title : str, optional Axis labels and plot title. cbar_label : str, optional Label for the colorbar. cbar_inset : bool, default: False Place colorbar as an inset (right) if True. xticks, yticks : list, optional Custom tick locations. annotations : list of dict, optional List of annotation dicts (e.g., {"text": "A", "xy": (lon, lat)}). export_path : str, optional Path to export the figure (without extension). export_formats : list, optional List of formats to export (e.g., ["png", "pdf"]). **kwargs : dict Additional keyword arguments for contourf.
Returns¶
fig : matplotlib.figure.Figure The matplotlib figure object. ax : matplotlib.axes.Axes The matplotlib axes object.
Source code in src/monet_plots/cartopy_utils.py
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 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 | |
plot_quick_imshow(da, map_kws=None, projection=None, colorbar=True, figsize=None, cmap=None, vmin=None, vmax=None, norm=None, dpi=150, xlabel=None, ylabel=None, title=None, cbar_label=None, cbar_inset=False, xticks=None, yticks=None, annotations=None, export_path=None, export_formats=None, **kwargs)
¶
Create a imshow plot of the data on a map using Cartopy.
Parameters¶
da : xarray.DataArray The data to plot. map_kws : dict, optional Dictionary of keyword arguments for map features (e.g., coastlines, gridlines, features, borders, land, ocean). projection : cartopy.crs.Projection, optional Cartopy projection to use. Defaults to PlateCarree. colorbar : bool, default: True Whether to add a colorbar. figsize : tuple, optional Figure size. cmap : str or Colormap, optional Colormap to use (supports colorblind-friendly options). vmin, vmax : float, optional Color limits. norm : Normalize, optional Matplotlib normalization (e.g., LogNorm). dpi : int, optional Dots per inch for export. xlabel, ylabel, title : str, optional Axis labels and plot title. cbar_label : str, optional Label for the colorbar. cbar_inset : bool, default: False Place colorbar as an inset (right) if True. xticks, yticks : list, optional Custom tick locations. annotations : list of dict, optional List of annotation dicts (e.g., {"text": "A", "xy": (lon, lat)}). export_path : str, optional Path to export the figure (without extension). export_formats : list, optional List of formats to export (e.g., ["png", "pdf"]). **kwargs : dict Additional keyword arguments for imshow.
Returns¶
fig : matplotlib.figure.Figure The matplotlib figure object. ax : matplotlib.axes.Axes The matplotlib axes object.
Source code in src/monet_plots/cartopy_utils.py
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 | |
plot_quick_map(da, map_kws=None, projection=None, colorbar=True, figsize=None, cmap=None, vmin=None, vmax=None, norm=None, dpi=150, xlabel=None, ylabel=None, title=None, cbar_label=None, cbar_inset=False, xticks=None, yticks=None, annotations=None, export_path=None, export_formats=None, **kwargs)
¶
Create a publication-quality map plot of the data using Cartopy and xarray's default plot method.
Parameters¶
da : xarray.DataArray The data to plot. map_kws : dict, optional Dictionary of keyword arguments for map features (e.g., coastlines, gridlines, features, borders, land, ocean). projection : cartopy.crs.Projection, optional Cartopy projection to use. Defaults to PlateCarree. colorbar : bool, default: True Whether to add a colorbar. figsize : tuple, optional Figure size. cmap : str or Colormap, optional Colormap to use (supports colorblind-friendly options). vmin, vmax : float, optional Color limits. norm : Normalize, optional Matplotlib normalization (e.g., LogNorm). dpi : int, optional Dots per inch for export. xlabel, ylabel, title : str, optional Axis labels and plot title. cbar_label : str, optional Label for the colorbar. cbar_inset : bool, default: False Place colorbar as an inset (right) if True. xticks, yticks : list, optional Custom tick locations. annotations : list of dict, optional List of annotation dicts (e.g., {"text": "A", "xy": (lon, lat)}). export_path : str, optional Path to export the figure (without extension). export_formats : list, optional List of formats to export (e.g., ["png", "pdf"]). **kwargs : dict Additional keyword arguments for xarray's plot method.
Returns¶
fig : matplotlib.figure.Figure The matplotlib figure object. ax : matplotlib.axes.Axes The matplotlib axes object.
Source code in src/monet_plots/cartopy_utils.py
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 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 | |
Colorbar helper functions
cmap_discretize(cmap, N)
¶
Return a discrete colormap from a continuous colormap.
Creates a new colormap by discretizing an existing continuous colormap into N distinct colors while preserving the color transitions.
Parameters¶
cmap : str or matplotlib.colors.Colormap Colormap instance or registered colormap name to discretize. Example: cm.jet, 'viridis', etc. N : int Number of discrete colors to use in the new colormap.
Returns¶
matplotlib.colors.LinearSegmentedColormap A new colormap object with N discrete colors based on the input colormap. The name will be the original colormap name with "_N" appended.
Source code in src/monet_plots/colorbars.py
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 | |
colorbar_index(ncolors, cmap, minval=None, maxval=None, dtype='int', basemap=None, ax=None, **kwargs)
¶
Create a colorbar with discrete colors and custom tick labels.
Parameters¶
ncolors : int Number of discrete colors to use in the colorbar. cmap : str or matplotlib.colors.Colormap Colormap to discretize and use for the colorbar. minval : float, optional Minimum value for the colorbar tick labels. If None and maxval is None, tick labels will range from 0 to ncolors. If None and maxval is provided, tick labels will range from 0 to maxval. maxval : float, optional Maximum value for the colorbar tick labels. If None, tick labels will range from 0 or minval to ncolors. dtype : str or type, default "int" Data type for tick label values (e.g., "int", "float"). basemap : matplotlib.mpl_toolkits.basemap.Basemap, optional Basemap instance to attach the colorbar to. If None, uses plt.colorbar. ax : matplotlib.axes.Axes, optional Axes to attach the colorbar to. If None, uses plt.gca(). **kwargs : Any Additional keyword arguments for plt.colorbar.
Returns¶
tuple (colorbar, discretized_cmap) where: - colorbar is the matplotlib.colorbar.Colorbar instance - discretized_cmap is the discretized colormap
Source code in src/monet_plots/colorbars.py
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 | |
get_discrete_scale(data, cmap='viridis', n_levels=10, vmin=None, vmax=None, extend='both')
¶
Get a discrete colormap and BoundaryNorm with 'nice' numbers.
Parameters¶
data : array-like The data to scale. cmap : str or matplotlib.colors.Colormap, optional The colormap to use, by default "viridis". n_levels : int, optional Target number of discrete levels, by default 10. vmin : float, optional Minimum value for the scale. vmax : float, optional Maximum value for the scale. extend : str, optional Whether to extend the scale ('neither', 'both', 'min', 'max'), by default "both".
Returns¶
tuple (colormap, BoundaryNorm)
Source code in src/monet_plots/colorbars.py
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 | |
get_diverging_scale(data, cmap='RdBu_r', center=0, span=None, p_span=None)
¶
Get a diverging colormap and normalization object centered at a value.
Parameters¶
data : array-like The data to scale. cmap : str or matplotlib.colors.Colormap, optional The colormap to use, by default "RdBu_r". center : float, optional The value to center the scale at, by default 0. span : float, optional The absolute range from the center (center +/- span). p_span : float, optional The percentile of absolute differences from center to use as span.
Returns¶
tuple (colormap, Normalize)
Source code in src/monet_plots/colorbars.py
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 | |
get_linear_scale(data, cmap='viridis', vmin=None, vmax=None, p_min=None, p_max=None)
¶
Get a linear colormap and normalization object.
Parameters¶
data : array-like The data to scale. cmap : str or matplotlib.colors.Colormap, optional The colormap to use, by default "viridis". vmin : float, optional Minimum value for the scale. If None, uses min(data) or p_min. vmax : float, optional Maximum value for the scale. If None, uses max(data) or p_max. p_min : float, optional Percentile for minimum value (0-100). p_max : float, optional Percentile for maximum value (0-100).
Returns¶
tuple (colormap, Normalize)
Source code in src/monet_plots/colorbars.py
9 10 11 12 13 14 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 | |
get_log_scale(data, cmap='viridis', vmin=None, vmax=None)
¶
Get a logarithmic colormap and normalization object.
Parameters¶
data : array-like The data to scale. cmap : str or matplotlib.colors.Colormap, optional The colormap to use, by default "viridis". vmin : float, optional Minimum value for the scale (>0). vmax : float, optional Maximum value for the scale.
Returns¶
tuple (colormap, LogNorm)
Source code in src/monet_plots/colorbars.py
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 | |
get_logo_path(name='monet_plots.png')
¶
Get the path to a bundled logo asset.
Parameters¶
name : str, optional The name of the logo file, by default "monet_plots.png".
Returns¶
str The full path to the logo file.
Source code in src/monet_plots/plot_utils.py
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | |
get_plot_kwargs(cmap=None, norm=None, **kwargs)
¶
Helper to prepare keyword arguments for plotting functions.
This function handles cases where cmap might be a tuple of
(colormap, norm) returned by the scaling tools in colorbars.py.
Parameters¶
cmap : Any, optional Colormap name, object, or (colormap, norm) tuple. norm : Any, optional Normalization object. **kwargs : Any Additional keyword arguments.
Returns¶
dict A dictionary of keyword arguments suitable for matplotlib plotting functions.
Source code in src/monet_plots/plot_utils.py
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 | |
normalize_data(data, prefer_xarray=True)
¶
Public API for normalizing data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
Input data of various types |
required |
prefer_xarray
|
bool
|
If True, attempts to convert non-pandas/non-xarray objects to xarray. If False, returns pandas objects as-is and converts others to DataFrame. |
True
|
Returns:
| Type | Description |
|---|---|
Any
|
Either an xarray DataArray, xarray Dataset, or pandas DataFrame |
Source code in src/monet_plots/plot_utils.py
285 286 287 288 289 290 291 292 293 294 295 296 297 | |
to_dataframe(data)
¶
Convert input data to a pandas DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
Input data. Can be a pandas DataFrame, xarray DataArray, xarray Dataset, or numpy ndarray. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
A pandas DataFrame. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input data type is not supported. |
Source code in src/monet_plots/plot_utils.py
14 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 | |
validate_data_array(data, required_dims=None)
¶
Validate data array parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
Data to validate |
required |
required_dims
|
Optional[list]
|
List of required dimension names |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If data type is invalid |
ValueError
|
If data dimensions are invalid |
Source code in src/monet_plots/plot_utils.py
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 | |
validate_dataframe(df, required_columns=None)
¶
Validate DataFrame parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
Any
|
DataFrame to validate |
required |
required_columns
|
Optional[list]
|
List of required column names |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If DataFrame type is invalid |
ValueError
|
If DataFrame structure is invalid |
Source code in src/monet_plots/plot_utils.py
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 | |
validate_plot_parameters(plot_class, method, **kwargs)
¶
Validate parameters for plot methods.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plot_class
|
str
|
The plot class name |
required |
method
|
str
|
The method name |
required |
**kwargs
|
Parameters to validate |
{}
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If parameter types are invalid |
ValueError
|
If parameter values are invalid |
Source code in src/monet_plots/plot_utils.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
BasePlot
¶
Base class for all plots.
Handles figure and axis creation, applies a consistent style, and provides a common interface for saving and closing plots.
Source code in src/monet_plots/plots/base.py
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 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 | |
__init__(fig=None, ax=None, style='wiley', **kwargs)
¶
Initializes the plot with a consistent style.
If fig and ax are not provided, a new figure and axes
are created.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fig
|
Figure
|
Figure to plot on. |
None
|
ax
|
Axes
|
Axes to plot on. |
None
|
style
|
str
|
Style name to apply (e.g., 'wiley', 'paper'). If None, no style is applied. Defaults to 'wiley'. |
'wiley'
|
**kwargs
|
Additional keyword arguments for |
{}
|
Source code in src/monet_plots/plots/base.py
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 | |
add_colorbar(mappable, *, ax=None, label=None, loc='right', size='5%', pad=0.05, **kwargs)
¶
Add a colorbar that matches the axes size.
This method uses inset_axes to ensure the colorbar height (or width)
matches the axes dimensions exactly, which is particularly useful for
geospatial plots with fixed aspects.
Parameters¶
mappable : matplotlib.cm.ScalarMappable
The mappable object (e.g., from imshow, scatter, contourf).
ax : matplotlib.axes.Axes, optional
The axes to attach the colorbar to. Defaults to self.ax.
label : str, optional
Label for the colorbar, by default None.
loc : str, optional
Location of the colorbar ('right', 'left', 'top', 'bottom'),
by default "right".
size : str, optional
Width (if vertical) or height (if horizontal) of the colorbar,
as a percentage of the axes, by default "5%".
pad : float, optional
Padding between the axes and the colorbar, by default 0.05.
**kwargs : Any
Additional keyword arguments passed to fig.colorbar.
Returns¶
matplotlib.colorbar.Colorbar The created colorbar object.
Source code in src/monet_plots/plots/base.py
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 | |
add_logo(logo=None, *, ax=None, loc='upper right', scale=0.1, pad=0.05, **kwargs)
¶
Adds a logo to the plot.
Parameters¶
logo : str or array-like, optional
Path to the logo image, a URL, or a numpy array.
If None, the default MONET logo is used.
ax : matplotlib.axes.Axes, optional
The axes to add the logo to. Defaults to self.ax.
loc : str, optional
Location of the logo ('upper right', 'upper left', 'lower right',
'lower left', 'center'). Defaults to "upper right".
scale : float, optional
Scaling factor for the logo, by default 0.1.
pad : float, optional
Padding from the edge of the axes, by default 0.05.
**kwargs : Any
Additional keyword arguments passed to AnnotationBbox.
Returns¶
matplotlib.offsetbox.AnnotationBbox The added logo object.
Source code in src/monet_plots/plots/base.py
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 | |
close()
¶
Closes the plot figure.
Source code in src/monet_plots/plots/base.py
62 63 64 | |
save(filename, **kwargs)
¶
Saves the plot to a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
The name of the file to save the plot to. |
required |
**kwargs
|
Additional keyword arguments for |
{}
|
Source code in src/monet_plots/plots/base.py
53 54 55 56 57 58 59 60 | |
BivariatePolarPlot
¶
Bases: BasePlot
Bivariate polar plot.
Shows how a variable varies with wind speed and wind direction. Uses polar coordinates where the angle represents wind direction and the radius represents wind speed.
Source code in src/monet_plots/plots/polar.py
12 13 14 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 | |
__init__(data, ws_col, wd_col, val_col, *, ws_max=None, **kwargs)
¶
Initialize Bivariate Polar Plot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
Input data (DataFrame, DataArray, etc.). |
required |
ws_col
|
str
|
Column name for wind speed. |
required |
wd_col
|
str
|
Column name for wind direction (degrees). |
required |
val_col
|
str
|
Column name for the value to plot. |
required |
ws_max
|
Optional[float]
|
Maximum wind speed to show. |
None
|
**kwargs
|
Arguments passed to BasePlot. Note: 'subplot_kw={"projection": "polar"}' is added automatically if not provided. |
{}
|
Source code in src/monet_plots/plots/polar.py
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 | |
plot(n_bins_ws=10, n_bins_wd=36, cmap='viridis', **kwargs)
¶
Generate the bivariate polar plot.
Uses binning to aggregate data before plotting.
Source code in src/monet_plots/plots/polar.py
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 | |
BrierScoreDecompositionPlot
¶
Bases: BasePlot
Brier Score Decomposition Plot.
Visualizes the components of the Brier Score: Reliability, Resolution, and Uncertainty. BS = Reliability - Resolution + Uncertainty
Source code in src/monet_plots/plots/brier_decomposition.py
11 12 13 14 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 | |
plot(data, reliability_col='reliability', resolution_col='resolution', uncertainty_col='uncertainty', forecasts_col=None, observations_col=None, n_bins=10, label_col=None, **kwargs)
¶
Main plotting method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
Input data. |
required |
reliability_col/resolution_col/uncertainty_col
|
str
|
Pre-computed component columns. |
required |
forecasts_col/observations_col
|
str
|
Raw forecast probabilities and binary observations. |
required |
n_bins
|
int
|
Bins for decomposition if raw data. |
10
|
label_col
|
str
|
Grouping column. |
None
|
**kwargs
|
Matplotlib kwargs. |
{}
|
Source code in src/monet_plots/plots/brier_decomposition.py
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 | |
ConditionalBiasPlot
¶
Bases: BasePlot
Conditional Bias Plot.
Visualizes the Bias (Forecast - Observation) as a function of the Observed Value. Supports native Xarray/Dask objects and interactive visualization.
Source code in src/monet_plots/plots/conditional_bias.py
13 14 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 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 | |
__init__(data=None, fig=None, ax=None, **kwargs)
¶
Initializes the plot.
Parameters¶
data : Any, optional The input data (Dataset, DataArray, DataFrame, or ndarray). fig : matplotlib.figure.Figure, optional Figure to plot on. ax : matplotlib.axes.Axes, optional Axes to plot on. **kwargs : Any Additional keyword arguments for the figure.
Source code in src/monet_plots/plots/conditional_bias.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |
hvplot(data=None, obs_col=None, fcst_col=None, n_bins=10, label_col=None, **kwargs)
¶
Generates an interactive plot using hvPlot.
Parameters¶
data : Any, optional Input data, overrides self.data if provided. obs_col : str, optional Name of the observation variable. fcst_col : str, optional Name of the forecast variable. n_bins : int, optional Number of bins, by default 10. label_col : str, optional Column name to group by. **kwargs : Any Additional hvPlot arguments.
Returns¶
holoviews.core.Element The interactive plot.
Source code in src/monet_plots/plots/conditional_bias.py
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 | |
plot(data=None, obs_col=None, fcst_col=None, n_bins=10, label='Model', label_col=None, **kwargs)
¶
Generates the static Matplotlib plot.
Parameters¶
data : Any, optional
Input data, overrides self.data if provided.
obs_col : str, optional
Name of the observation variable. Required for Dataset/DataFrame.
fcst_col : str, optional
Name of the forecast variable. Required for Dataset/DataFrame.
n_bins : int, optional
Number of bins for observed values, by default 10.
label : str, optional
Label for the model data, by default "Model".
label_col : str, optional
Column name to group by for plotting multiple lines.
**kwargs : Any
Additional Matplotlib plotting arguments passed to errorbar.
Returns¶
matplotlib.axes.Axes The axes object containing the plot.
Source code in src/monet_plots/plots/conditional_bias.py
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 | |
ConditionalQuantilePlot
¶
Bases: BasePlot
Conditional quantile plot.
Plots the distribution (quantiles) of modeled values as a function of binned observed values. This helps identify if the model's uncertainty or bias changes across the range of observations.
Source code in src/monet_plots/plots/conditional_quantile.py
14 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 | |
__init__(data, obs_col, mod_col, *, bins=10, quantiles=[0.25, 0.5, 0.75], **kwargs)
¶
Initialize Conditional Quantile Plot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
Input data (DataFrame, DataArray, etc.). |
required |
obs_col
|
str
|
Column name for observations. |
required |
mod_col
|
str
|
Column name for model values. |
required |
bins
|
Union[int, List[float]]
|
Number of bins or bin edges for observations. |
10
|
quantiles
|
List[float]
|
List of quantiles to calculate (0 to 1). |
[0.25, 0.5, 0.75]
|
**kwargs
|
Arguments passed to BasePlot. |
{}
|
Source code in src/monet_plots/plots/conditional_quantile.py
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 | |
plot(show_points=False, **kwargs)
¶
Generate the conditional quantile plot.
Source code in src/monet_plots/plots/conditional_quantile.py
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 | |
CurtainPlot
¶
Bases: BasePlot
Vertical curtain plot for cross-sectional data.
This plot shows a 2D variable (e.g., concentration) as a function of one horizontal dimension (time or distance) and one vertical dimension (altitude or pressure).
Source code in src/monet_plots/plots/curtain.py
12 13 14 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 | |
__init__(data, *, x=None, y=None, **kwargs)
¶
Initialize Curtain Plot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
Input data. Should be a 2D xarray.DataArray or similar. |
required |
x
|
Optional[str]
|
Name of the x-axis dimension/coordinate (e.g., 'time'). |
None
|
y
|
Optional[str]
|
Name of the y-axis dimension/coordinate (e.g., 'level'). |
None
|
**kwargs
|
Arguments passed to BasePlot. |
{}
|
Source code in src/monet_plots/plots/curtain.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
plot(kind='pcolormesh', colorbar=True, **kwargs)
¶
Generate the curtain plot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
str
|
Type of plot ('pcolormesh' or 'contourf'). |
'pcolormesh'
|
colorbar
|
bool
|
Whether to add a colorbar. |
True
|
**kwargs
|
Additional arguments for the plotting function. |
{}
|
Source code in src/monet_plots/plots/curtain.py
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 | |
DiurnalErrorPlot
¶
Bases: BasePlot
Diurnal error heat map.
Visualizes model error (bias) as a function of the hour of day and another temporal dimension (e.g., month, day of week, or date).
This class supports native Xarray and Dask objects for lazy evaluation and provenance tracking.
Attributes¶
data : Union[xr.Dataset, xr.DataArray, pd.DataFrame] The input data for the plot. obs_col : str Column/variable name for observations. mod_col : str Column/variable name for model values. time_col : str Dimension/column name for timestamp. second_dim : str The second dimension for the heatmap. metric : str The metric to plot ('bias' or 'error'). aggregated : xr.DataArray The calculated aggregated data for the heatmap. second_label : str The label for the second dimension on the y-axis.
Examples¶
import pandas as pd import numpy as np from monet_plots.plots import DiurnalErrorPlot dates = pd.date_range("2023-01-01", periods=100, freq="h") df = pd.DataFrame({ ... "time": dates, ... "obs": np.random.rand(100), ... "mod": np.random.rand(100) ... }) plot = DiurnalErrorPlot(df, obs_col="obs", mod_col="mod") ax = plot.plot()
Source code in src/monet_plots/plots/diurnal_error.py
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 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 | |
__init__(data, obs_col, mod_col, *, time_col='time', second_dim='month', metric='bias', fig=None, ax=None, **kwargs)
¶
Initialize Diurnal Error Plot.
Parameters¶
data : Any Input data. Can be a pandas DataFrame, xarray DataArray, xarray Dataset, or dask-backed object. obs_col : str Column/variable name for observations. mod_col : str Column/variable name for model values. time_col : str, optional Dimension/column name for timestamp, by default "time". second_dim : str, optional The second dimension for the heatmap ('month', 'dayofweek', 'date', or a coordinate name), by default "month". metric : str, optional The metric to plot ('bias' or 'error'), by default "bias". fig : matplotlib.figure.Figure, optional Existing figure object, by default None. ax : matplotlib.axes.Axes, optional Existing axes object, by default None. **kwargs : Any Additional arguments passed to BasePlot.
Source code in src/monet_plots/plots/diurnal_error.py
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 | |
hvplot(cmap='RdBu_r', **kwargs)
¶
Generate the diurnal error heatmap (Track B: Interactive).
Parameters¶
cmap : str, optional Colormap to use, by default "RdBu_r". **kwargs : Any Additional arguments passed to hvplot.heatmap.
Returns¶
holoviews.Element The interactive HoloViews object.
Examples¶
Assuming 'plot' is a DiurnalErrorPlot instance¶
interactive_plot = plot.hvplot()
Source code in src/monet_plots/plots/diurnal_error.py
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 | |
plot(cmap='RdBu_r', **kwargs)
¶
Generate the diurnal error heatmap (Track A: Static).
Parameters¶
cmap : str, optional Colormap to use, by default "RdBu_r". **kwargs : Any Additional arguments passed to sns.heatmap.
Returns¶
matplotlib.axes.Axes The axes object.
Examples¶
Assuming 'plot' is a DiurnalErrorPlot instance¶
ax = plot.plot(cmap="viridis")
Source code in src/monet_plots/plots/diurnal_error.py
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 | |
FacetGridPlot
¶
Bases: BasePlot
Creates a facet grid plot.
This class creates a facet grid plot using seaborn's FacetGrid.
Source code in src/monet_plots/plots/facet_grid.py
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 164 165 166 167 168 169 170 171 | |
__init__(data, row=None, col=None, hue=None, col_wrap=None, size=None, aspect=1, subplot_kws=None, style='wiley', **kwargs)
¶
Initializes the facet grid.
Parameters¶
data : Any
The data to plot.
row : str, optional
Variable to map to row facets, by default None.
col : str, optional
Variable to map to column facets, by default None.
hue : str, optional
Variable to map to color mapping, by default None.
col_wrap : int, optional
Number of columns before wrapping, by default None.
size : float, optional
Height (in inches) of each facet, by default 3.
Aligns with Xarray convention.
aspect : float, optional
Aspect ratio of each facet, by default 1.
subplot_kws : dict, optional
Keyword arguments for subplots (e.g. projection).
style : str, optional
Style name to apply, by default "wiley".
**kwargs : Any
Additional keyword arguments to pass to FacetGrid.
height is supported as an alias for size (Seaborn convention).
Source code in src/monet_plots/plots/facet_grid.py
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 | |
close()
¶
Closes the plot.
Source code in src/monet_plots/plots/facet_grid.py
169 170 171 | |
map_dataframe(plot_func, *args, **kwargs)
¶
Maps a plotting function to the facet grid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plot_func
|
function
|
The plotting function to map. |
required |
*args
|
Any
|
Positional arguments to pass to the plotting function. |
()
|
**kwargs
|
Any
|
Keyword arguments to pass to the plotting function. |
{}
|
Source code in src/monet_plots/plots/facet_grid.py
130 131 132 133 134 135 136 137 138 | |
plot(plot_func=None, *args, **kwargs)
¶
Plots the data using the FacetGrid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plot_func
|
function
|
The plotting function to use. |
None
|
*args
|
Positional arguments to pass to the plotting function. |
()
|
|
**kwargs
|
Keyword arguments to pass to the plotting function. |
{}
|
Source code in src/monet_plots/plots/facet_grid.py
158 159 160 161 162 163 164 165 166 167 | |
save(filename, **kwargs)
¶
Saves the plot to a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
The name of the file to save the plot to. |
required |
**kwargs
|
Additional keyword arguments to pass to |
{}
|
Source code in src/monet_plots/plots/facet_grid.py
149 150 151 152 153 154 155 156 | |
set_titles(*args, **kwargs)
¶
Sets the titles of the facet grid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Positional arguments to pass to |
()
|
|
**kwargs
|
Keyword arguments to pass to |
{}
|
Source code in src/monet_plots/plots/facet_grid.py
140 141 142 143 144 145 146 147 | |
FingerprintPlot
¶
Bases: BasePlot
Fingerprint plot.
Displays a variable as a heatmap across two different temporal scales, such as hour of day vs. day of year, to reveal periodic patterns.
Source code in src/monet_plots/plots/fingerprint.py
13 14 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 | |
__init__(data, val_col, *, time_col='time', x_scale='hour', y_scale='dayofyear', **kwargs)
¶
Initialize Fingerprint Plot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
Input data (DataFrame, DataArray, etc.). |
required |
val_col
|
str
|
Column name of the value to plot. |
required |
time_col
|
str
|
Column name for timestamp. |
'time'
|
x_scale
|
str
|
Temporal scale for the x-axis ('hour', 'month', 'dayofweek', etc.). |
'hour'
|
y_scale
|
str
|
Temporal scale for the y-axis ('dayofyear', 'year', 'week', etc.). |
'dayofyear'
|
**kwargs
|
Arguments passed to BasePlot. |
{}
|
Source code in src/monet_plots/plots/fingerprint.py
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 | |
plot(cmap='viridis', **kwargs)
¶
Generate the fingerprint heatmap.
Source code in src/monet_plots/plots/fingerprint.py
78 79 80 81 82 83 84 85 86 87 88 89 90 | |
KDEPlot
¶
Bases: BasePlot
Create a kernel density estimate plot.
This plot shows the distribution of a single variable.
Source code in src/monet_plots/plots/kde.py
8 9 10 11 12 13 14 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 | |
__init__(df, x, y, title=None, label=None, *args, **kwargs)
¶
Initialize the plot with data and plot settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
(DataFrame, ndarray, Dataset, DataArray)
|
DataFrame with the data to plot. |
required |
x
|
str
|
Column name for the x-axis. |
required |
y
|
str
|
Column name for the y-axis. |
required |
title
|
str
|
Title for the plot. |
None
|
label
|
str
|
Label for the plot. |
None
|
Source code in src/monet_plots/plots/kde.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | |
plot(**kwargs)
¶
Generate the KDE plot.
Source code in src/monet_plots/plots/kde.py
32 33 34 35 36 37 38 39 40 41 | |
PerformanceDiagramPlot
¶
Bases: BasePlot
Performance Diagram Plot (Roebber).
Visualizes the relationship between Probability of Detection (POD), Success Ratio (SR), Critical Success Index (CSI), and Bias.
Functional Requirements: 1. Plot POD (y-axis) vs Success Ratio (x-axis). 2. Draw background isolines for CSI and Bias. 3. Support input as pre-calculated metrics or contingency table counts. 4. Handle multiple models/configurations via grouping.
Edge Cases: - SR or POD being 0 or 1 (division by zero in bias/CSI calculations). - Empty DataFrame. - Missing required columns.
Source code in src/monet_plots/plots/performance_diagram.py
10 11 12 13 14 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 | |
plot(data, x_col='success_ratio', y_col='pod', counts_cols=None, label_col=None, **kwargs)
¶
Main plotting method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
(DataFrame, ndarray, Dataset, DataArray)
|
Input data. |
required |
x_col
|
str
|
Column name for Success Ratio (1-FAR). |
'success_ratio'
|
y_col
|
str
|
Column name for POD. |
'pod'
|
counts_cols
|
list
|
List of columns [hits, misses, fa, cn] to calculate metrics if x_col/y_col not present. |
None
|
label_col
|
str
|
Column to use for legend labels. |
None
|
**kwargs
|
Matplotlib kwargs. |
{}
|
Source code in src/monet_plots/plots/performance_diagram.py
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 | |
ProfilePlot
¶
Bases: BasePlot
Profile or cross-section plot.
Source code in src/monet_plots/plots/profile.py
12 13 14 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 | |
__init__(*, x, y, z=None, alt_adjust=None, **kwargs)
¶
Parameters¶
x X-axis data. y Y-axis data. z Optional Z-axis data for contour plots. alt_adjust Value to subtract from the y-axis data for altitude adjustment. **kwargs Keyword arguments passed to the parent class.
Source code in src/monet_plots/plots/profile.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 | |
plot(**kwargs)
¶
Parameters¶
**kwargs
Keyword arguments passed to matplotlib.pyplot.plot or
matplotlib.pyplot.contourf.
Source code in src/monet_plots/plots/profile.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
ROCCurvePlot
¶
Bases: BasePlot
Receiver Operating Characteristic (ROC) Curve Plot.
Visualizes the trade-off between Probability of Detection (POD) and Probability of False Detection (POFD).
Functional Requirements: 1. Plot POD (y-axis) vs POFD (x-axis). 2. Draw diagonal "no skill" line (0,0) to (1,1). 3. Calculate and display Area Under Curve (AUC) in legend. 4. Support multiple models/curves via grouping.
Edge Cases: - Non-monotonic data points (should sort by threshold/prob). - Single point provided (cannot calculate AUC properly, return NaN or handle gracefully). - Missing columns.
Source code in src/monet_plots/plots/roc_curve.py
8 9 10 11 12 13 14 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 | |
plot(data, x_col='pofd', y_col='pod', label_col=None, show_auc=True, **kwargs)
¶
Main plotting method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
(DataFrame, ndarray, Dataset, DataArray)
|
Input data containing ROC points. |
required |
x_col
|
str
|
Column name for POFD (False Alarm Rate). |
'pofd'
|
y_col
|
str
|
Column name for POD (Hit Rate). |
'pod'
|
label_col
|
str
|
Column for grouping different curves. |
None
|
show_auc
|
bool
|
Whether to calculate and append AUC to labels. |
True
|
**kwargs
|
Matplotlib kwargs. |
{}
|
Source code in src/monet_plots/plots/roc_curve.py
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 | |
RankHistogramPlot
¶
Bases: BasePlot
Rank Histogram (Talagrand Diagram).
Visualizes the distribution of observation ranks within an ensemble.
Functional Requirements: 1. Plot bar chart of rank frequencies. 2. Draw horizontal line for "Perfect Flatness" (uniform distribution). 3. Support normalizing frequencies (relative frequency) or raw counts. 4. Interpret shapes: U-shape (underdispersed), A-shape (overdispersed), Bias (slope).
Edge Cases: - Unequal ensemble sizes (requires binning or normalization logic, but typically preprocessing handles this). - Missing ranks (should be 0 height bars).
Source code in src/monet_plots/plots/rank_histogram.py
9 10 11 12 13 14 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 | |
plot(data, rank_col='rank', n_members=None, label_col=None, normalize=True, **kwargs)
¶
Main plotting method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
(DataFrame, ndarray, Dataset, DataArray)
|
Data containing ranks (0 to n_members). |
required |
rank_col
|
str
|
Column containing the rank of the observation. |
'rank'
|
n_members
|
Optional[int]
|
Number of ensemble members (defines n_bins = n_members + 1). Inferred from max(rank) if None. |
None
|
label_col
|
Optional[str]
|
Grouping for multiple histograms (e.g., lead times). |
None
|
normalize
|
bool
|
If True, plot relative frequency; else raw counts. |
True
|
**kwargs
|
Matplotlib kwargs. |
{}
|
Source code in src/monet_plots/plots/rank_histogram.py
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 | |
RelativeEconomicValuePlot
¶
Bases: BasePlot
Relative Economic Value (REV) Plot.
Visualizes the potential economic value of a forecast system relative to climatology.
Functional Requirements: 1. Plot Value (y-axis) vs Cost/Loss Ratio (x-axis). 2. Calculate REV based on Hits, Misses, False Alarms, Correct Negatives. 3. Support multiple models. 4. X-axis usually logarithmic or specific range [0, 1].
Edge Cases: - C/L ratio 0 or 1 (value is 0). - No events observed (metrics undefined).
Source code in src/monet_plots/plots/rev.py
10 11 12 13 14 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 | |
plot(data, counts_cols=['hits', 'misses', 'fa', 'cn'], climatology=None, label_col=None, cost_loss_ratios=None, **kwargs)
¶
Main plotting method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
(DataFrame, ndarray, Dataset, DataArray)
|
Input data with contingency table counts. |
required |
counts_cols
|
List[str]
|
Contingency table columns [hits, misses, fa, cn]. |
['hits', 'misses', 'fa', 'cn']
|
climatology
|
Optional[float]
|
Sample climatology (base rate). Computed if None. |
None
|
label_col
|
Optional[str]
|
Grouping column for multiple curves. |
None
|
cost_loss_ratios
|
Optional[ndarray]
|
Array of C/L ratios. Default linspace(0.001,0.999,100). |
None
|
**kwargs
|
Matplotlib kwargs. |
{}
|
Source code in src/monet_plots/plots/rev.py
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 | |
ReliabilityDiagramPlot
¶
Bases: BasePlot
Reliability Diagram Plot (Attributes Diagram).
Visualizes Observed Frequency vs Forecast Probability.
Functional Requirements: 1. Plot Observed Frequency (y-axis) vs Forecast Probability (x-axis). 2. Draw "Perfect Reliability" diagonal (1:1). 3. Draw "No Skill" line (horizontal at climatology/sample mean). 4. Shade "Skill" areas (where Brier Skill Score > 0). 5. Include inset histogram of forecast usage (Sharpness) if requested.
Edge Cases: - Empty bins (no forecasts with that probability). - Climatology not provided (cannot draw skill regions correctly).
Source code in src/monet_plots/plots/reliability_diagram.py
11 12 13 14 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 | |
plot(data, x_col='prob', y_col='freq', forecasts_col=None, observations_col=None, n_bins=10, climatology=None, label_col=None, show_hist=False, **kwargs)
¶
Main plotting method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
Input data. |
required |
x_col
|
str
|
Forecast Probability bin center (for pre-binned). |
'prob'
|
y_col
|
str
|
Observed Frequency in bin (for pre-binned). |
'freq'
|
forecasts_col
|
str
|
Column of raw forecast probabilities [0,1]. |
None
|
observations_col
|
str
|
Column of binary observations {0,1}. |
None
|
n_bins
|
int
|
Number of bins for reliability curve computation. |
10
|
climatology
|
Optional[float]
|
Sample climatology (mean(observations)). |
None
|
label_col
|
str
|
Grouping column. |
None
|
show_hist
|
bool
|
Whether to show frequency of usage histogram. |
False
|
**kwargs
|
Matplotlib kwargs. |
{}
|
Source code in src/monet_plots/plots/reliability_diagram.py
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 | |
RidgelinePlot
¶
Bases: BasePlot
Creates a ridgeline plot (joyplot) from an xarray DataArray or pandas DataFrame.
A ridgeline plot shows the distribution of a numeric value for several groups. Each group has its own distribution curve, often overlapping with others.
Attributes:
| Name | Type | Description |
|---|---|---|
data |
DataArray | Dataset | DataFrame
|
Normalized input data. |
group_dim |
str
|
The dimension or column to group by for the Y-axis. |
x |
str | None
|
The column name for values if data is a DataFrame or Dataset. |
x_range |
tuple | None
|
Tuple (min, max) for the x-axis limits. |
scale_factor |
float
|
Height scaling of the curves. |
overlap |
float
|
Vertical spacing between curves. |
cmap_name |
str
|
Colormap name for coloring curves. |
title |
str | None
|
Plot title. |
Source code in src/monet_plots/plots/ridgeline.py
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 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 | |
__init__(data, group_dim, x=None, *, x_range=None, scale_factor=1.0, overlap=0.5, cmap='RdBu_r', title=None, bw_method=None, alpha=0.8, quantiles=None, **kwargs)
¶
Initializes the ridgeline plot with data and settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
The data to plot (xr.DataArray, xr.Dataset, or pd.DataFrame). |
required |
group_dim
|
str
|
The dimension or column to group by for the Y-axis. |
required |
x
|
str
|
The variable/column to plot distributions of. Required if data is a Dataset or DataFrame with multiple variables. |
None
|
x_range
|
tuple[float, float]
|
Tuple (min, max) for the x-axis limits. If None, auto-calculated. |
None
|
scale_factor
|
float
|
Height scaling of the curves. Defaults to 1.0. |
1.0
|
overlap
|
float
|
Vertical spacing between curves. Higher values mean more overlap. Defaults to 0.5. |
0.5
|
cmap
|
str
|
Colormap name for coloring curves. Defaults to 'RdBu_r'. |
'RdBu_r'
|
title
|
str
|
Plot title. |
None
|
bw_method
|
Any
|
KDE bandwidth method (passed to scipy.stats.gaussian_kde). |
None
|
alpha
|
float
|
Transparency of the ridges. Defaults to 0.8. |
0.8
|
quantiles
|
list[float]
|
List of quantiles to display (e.g., [0.5]). |
None
|
**kwargs
|
Any
|
Additional keyword arguments for BasePlot (figure/axes creation). |
{}
|
Source code in src/monet_plots/plots/ridgeline.py
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 | |
plot(gradient=True, color_by_group=False, **kwargs)
¶
Generate the ridgeline plot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gradient
|
bool
|
If True, fill curves with a gradient based on x-values. |
True
|
color_by_group
|
bool
|
If True, color each ridge by its group category. Takes precedence over gradient if True. |
False
|
**kwargs
|
Any
|
Additional keyword arguments for formatting. |
{}
|
Returns:
| Type | Description |
|---|---|
Axes
|
matplotlib.axes.Axes: The axes object containing the plot. |
Source code in src/monet_plots/plots/ridgeline.py
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 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 | |
ScatterPlot
¶
Bases: BasePlot
Create a scatter plot with a regression line.
This plot shows the relationship between two variables and includes a linear regression model fit. It supports lazy evaluation for large Xarray/Dask datasets by delaying computation until the plot call.
Attributes¶
data : Union[xr.Dataset, xr.DataArray, pd.DataFrame] The input data for the plot. x : str The name of the variable for the x-axis. y : List[str] The names of the variables for the y-axis. c : Optional[str] The name of the variable used for colorizing points. colorbar : bool Whether to add a colorbar to the plot. title : Optional[str] The title for the plot.
Source code in src/monet_plots/plots/scatter.py
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 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 | |
__init__(data=None, x=None, y=None, c=None, colorbar=False, title=None, fig=None, ax=None, df=None, **kwargs)
¶
Initialize the scatter plot.
Parameters¶
data : Any, optional
Input data. Can be a pandas DataFrame, xarray DataArray,
xarray Dataset, or numpy ndarray, by default None.
x : str, optional
Variable name for the x-axis, by default None.
y : Union[str, List[str]], optional
Variable name(s) for the y-axis, by default None.
c : str, optional
Variable name for colorizing the points, by default None.
colorbar : bool, optional
Whether to add a colorbar, by default False.
title : str, optional
Title for the plot, by default None.
fig : matplotlib.figure.Figure, optional
An existing Figure object, by default None.
ax : matplotlib.axes.Axes, optional
An existing Axes object, by default None.
df : Any, optional
Alias for data for backward compatibility, by default None.
**kwargs : Any
Additional keyword arguments passed to BasePlot.
Source code in src/monet_plots/plots/scatter.py
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 | |
hvplot(**kwargs)
¶
Generate an interactive scatter plot using hvPlot (Track B).
Parameters¶
**kwargs : Any
Keyword arguments passed to hvplot.scatter.
Common options include cmap, title, and alpha.
rasterize=True is used by default for high performance.
Returns¶
holoviews.core.layout.Layout The interactive hvPlot object.
Source code in src/monet_plots/plots/scatter.py
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 | |
plot(scatter_kws=None, line_kws=None, **kwargs)
¶
Generate a static publication-quality scatter plot (Track A).
Parameters¶
scatter_kws : dict, optional
Additional keyword arguments for ax.scatter.
line_kws : dict, optional
Additional keyword arguments for the regression ax.plot.
**kwargs : Any
Secondary way to pass keyword arguments to ax.scatter.
Merged with scatter_kws.
Returns¶
matplotlib.axes.Axes The axes object with the scatter plot.
Notes¶
For massive datasets (> RAM), consider using Track B (Exploration)
tools like hvplot with rasterize=True.
Source code in src/monet_plots/plots/scatter.py
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 | |
ScorecardPlot
¶
Bases: BasePlot
Scorecard Plot.
Heatmap table displaying performance metrics across multiple dimensions (e.g., Variables vs Lead Times), colored by performance relative to a baseline.
Functional Requirements: 1. Heatmap grid: Rows (Variables/Regions), Cols (Lead Times/Levels). 2. Color cells based on statistic (e.g., Difference from Baseline, RMSE ratio). 3. Annotate cells with symbols (+/-) or values indicating significance. 4. Handle Green (Better) / Red (Worse) color schemes correctly.
Edge Cases: - Missing data for some cells (show as white/gray). - Infinite values (clip or mask).
Source code in src/monet_plots/plots/scorecard.py
10 11 12 13 14 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 164 165 166 167 168 169 170 171 | |
plot(data, x_col, y_col, val_col, sig_col=None, cmap='RdYlGn', center=0.0, annot_cols=None, cbar_labels=None, key_text=None, **kwargs)
¶
Main plotting method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
(DataFrame, ndarray, Dataset, DataArray)
|
Long-format dataframe. |
required |
x_col
|
str
|
Column for x-axis (Columns). |
required |
y_col
|
str
|
Column for y-axis (Rows). |
required |
val_col
|
str
|
Column for cell values (color). |
required |
sig_col
|
str
|
Column for significance (marker). |
None
|
cmap
|
str
|
Colormap. |
'RdYlGn'
|
center
|
float
|
Center value for colormap divergence. |
0.0
|
annot_cols
|
list[str]
|
Columns to combine for cell annotations (e.g., ['mod', 'obs']). |
None
|
cbar_labels
|
tuple[str, str]
|
Labels for the left and right ends of the colorbar. |
None
|
key_text
|
str
|
Text to display in a legend box at the top right. |
None
|
**kwargs
|
Seaborn heatmap kwargs. |
{}
|
Source code in src/monet_plots/plots/scorecard.py
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 | |
SoccerPlot
¶
Bases: BasePlot
Soccer plot for model evaluation.
This plot shows model performance by plotting bias (x-axis) against error (y-axis). It typically includes 'goal' and 'criteria' zones to visually assess if the model meets specific performance standards.
Attributes¶
data : Union[pd.DataFrame, xr.Dataset, xr.DataArray] The input data for the plot. bias_data : Union[pd.Series, xr.DataArray] Calculated or provided bias values. error_data : Union[pd.Series, xr.DataArray] Calculated or provided error values.
Source code in src/monet_plots/plots/soccer.py
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 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 | |
__init__(data, *, obs_col=None, mod_col=None, bias_col=None, error_col=None, label_col=None, metric='fractional', goal={'bias': 30.0, 'error': 50.0}, criteria={'bias': 60.0, 'error': 75.0}, fig=None, ax=None, **kwargs)
¶
Initialize Soccer Plot.
Parameters¶
data : Any Input data. Can be a pandas DataFrame, xarray DataArray, xarray Dataset, or numpy ndarray. obs_col : str, optional Column name for observations. Required if bias/error not provided. mod_col : str, optional Column name for model values. Required if bias/error not provided. bias_col : str, optional Column name for pre-calculated bias. error_col : str, optional Column name for pre-calculated error. label_col : str, optional Column name for labeling points. metric : str, optional Type of metric to calculate if obs/mod provided ('fractional' or 'normalized'), by default "fractional". goal : Dict[str, float], optional Dictionary with 'bias' and 'error' thresholds for the goal zone, by default {"bias": 30.0, "error": 50.0}. criteria : Dict[str, float], optional Dictionary with 'bias' and 'error' thresholds for the criteria zone, by default {"bias": 60.0, "error": 75.0}. fig : matplotlib.figure.Figure, optional An existing Figure object. ax : matplotlib.axes.Axes, optional An existing Axes object. **kwargs : Any Arguments passed to BasePlot.
Source code in src/monet_plots/plots/soccer.py
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 | |
hvplot(**kwargs)
¶
Generate an interactive soccer plot using hvPlot (Track B).
Parameters¶
**kwargs : Any
Keyword arguments passed to hvplot.scatter.
Returns¶
holoviews.core.Element The interactive soccer plot.
Source code in src/monet_plots/plots/soccer.py
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 | |
plot(**kwargs)
¶
Generate the soccer plot.
Parameters¶
**kwargs : Any
Keyword arguments passed to ax.scatter.
Returns¶
matplotlib.axes.Axes The axes object with the soccer plot.
Source code in src/monet_plots/plots/soccer.py
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 | |
SpatialBiasScatterPlot
¶
Bases: SpatialPlot
Create a spatial scatter plot showing bias between model and observations.
The scatter points are colored by the difference (model - observations) and sized by the absolute magnitude of this difference, making larger biases more visible. This class supports both Track A (publication) and Track B (interactive) visualization.
Source code in src/monet_plots/plots/spatial_bias_scatter.py
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 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 | |
__init__(data, col1, col2, vmin=None, vmax=None, ncolors=15, fact=1.5, cmap='RdBu_r', **kwargs)
¶
Initialize the plot with data and map projection.
Parameters¶
data : Any
Input data. Preferred format is xarray.Dataset or xarray.DataArray
with 'latitude' and 'longitude' (or 'lat' and 'lon') coordinates.
col1 : str
Name of the first variable (e.g., observations).
col2 : str
Name of the second variable (e.g., model). Bias is calculated
as col2 - col1.
vmin : float, optional
Minimum for colorscale, by default None.
vmax : float, optional
Maximum for colorscale, by default None.
ncolors : int, optional
Number of discrete colors, by default 15.
fact : float, optional
Scaling factor for point sizes, by default 1.5.
cmap : str, optional
Colormap for bias values, by default "RdBu_r".
**kwargs : Any
Additional keyword arguments for map creation, passed to
:class:monet_plots.plots.spatial.SpatialPlot.
Source code in src/monet_plots/plots/spatial_bias_scatter.py
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 | |
hvplot(**kwargs)
¶
Generate an interactive spatial bias scatter plot using hvPlot (Track B).
Parameters¶
**kwargs : Any
Keyword arguments passed to hvplot.points.
Common options include cmap, title, and alpha.
rasterize=True is used by default for high performance.
Returns¶
holoviews.core.layout.Layout The interactive hvPlot object.
Source code in src/monet_plots/plots/spatial_bias_scatter.py
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 | |
plot(**kwargs)
¶
Generate a static publication-quality spatial bias scatter plot (Track A).
Parameters¶
**kwargs : Any
Keyword arguments passed to matplotlib.pyplot.scatter.
Map features (e.g., coastlines=True) can also be passed here.
Returns¶
matplotlib.axes.Axes The matplotlib axes object containing the plot.
Source code in src/monet_plots/plots/spatial_bias_scatter.py
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 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 | |
SpatialContourPlot
¶
Bases: SpatialPlot
Create a contour plot on a map with an optional discrete colorbar.
This class provides an xarray-native interface for visualizing spatial data with continuous values. It supports both Track A (publication-quality static plots) and Track B (interactive exploration).
Source code in src/monet_plots/plots/spatial_contour.py
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 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 | |
__init__(modelvar, gridobj=None, date=None, discrete=True, ncolors=None, dtype='int', col=None, row=None, col_wrap=None, size=None, aspect=None, **kwargs)
¶
Initialize the spatial contour plot.
Parameters¶
modelvar : Any
The input data to contour. Preferred format is an xarray DataArray.
gridobj : Any, optional
Object with LAT and LON variables to determine extent, by default None.
date : datetime, optional
Date/time for the plot title, by default None.
discrete : bool, optional
If True, use a discrete colorbar, by default True.
ncolors : int, optional
Number of discrete colors for the colorbar, by default None.
dtype : str, optional
Data type for colorbar tick labels, by default "int".
col : str, optional
Dimension name to facet by columns. Aligns with Xarray.
row : str, optional
Dimension name to facet by rows. Aligns with Xarray.
col_wrap : int, optional
Number of columns before wrapping. Aligns with Xarray.
size : float, optional
Height (in inches) of each facet. Aligns with Xarray.
aspect : float, optional
Aspect ratio of each facet. Aligns with Xarray.
**kwargs : Any
Keyword arguments passed to :class:SpatialPlot for map features
and projection.
Source code in src/monet_plots/plots/spatial_contour.py
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 | |
__new__(modelvar, gridobj=None, date=None, **kwargs)
¶
Redirect to SpatialFacetGridPlot if faceting is requested.
This enables a unified interface for both single-panel and multi-panel spatial plots, following Xarray's plotting conventions.
Parameters¶
modelvar : Any
The input data to contour.
gridobj : Any, optional
Object with LAT and LON variables, by default None.
date : Any, optional
Date/time for the plot title, by default None.
**kwargs : Any
Additional keyword arguments. If faceting arguments (e.g., col,
row, or col_wrap) are provided, redirects to SpatialFacetGridPlot.
Returns¶
Any An instance of SpatialContourPlot or SpatialFacetGridPlot.
Source code in src/monet_plots/plots/spatial_contour.py
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 | |
hvplot(**kwargs)
¶
Generate an interactive spatial contour plot using hvPlot (Track B).
Parameters¶
**kwargs : Any
Keyword arguments passed to hvplot.contourf.
Common options include cmap, levels, title, and alpha.
Returns¶
holoviews.core.layout.Layout The interactive hvPlot object.
Source code in src/monet_plots/plots/spatial_contour.py
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 | |
plot(**kwargs)
¶
Generate a static publication-quality spatial contour plot (Track A).
Parameters¶
**kwargs : Any
Keyword arguments passed to matplotlib.pyplot.contourf.
Common options include cmap, levels, vmin, vmax, and alpha.
Map features (e.g., coastlines=True) can also be passed here.
Returns¶
matplotlib.axes.Axes The matplotlib axes object containing the plot.
Source code in src/monet_plots/plots/spatial_contour.py
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 | |
SpatialImshowPlot
¶
Bases: SpatialPlot
Create a basic spatial plot using imshow.
This class provides an xarray-native interface for visualizing 2D model data on a map. It supports both Track A (publication-quality static plots) and Track B (interactive exploration).
Source code in src/monet_plots/plots/spatial_imshow.py
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 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 | |
__init__(modelvar, gridobj=None, plotargs=None, ncolors=15, discrete=False, col=None, row=None, col_wrap=None, size=None, aspect=None, **kwargs)
¶
Initialize the spatial imshow plot.
Parameters¶
modelvar : Any
The input data to plot. Preferred format is an xarray DataArray.
gridobj : Any, optional
Object with LAT and LON variables to determine extent, by default None.
plotargs : dict, optional
Arguments for imshow, by default None.
ncolors : int, optional
Number of discrete colors for the discrete colorbar, by default 15.
discrete : bool, optional
If True, use a discrete colorbar, by default False.
col : str, optional
Dimension name to facet by columns. Aligns with Xarray.
row : str, optional
Dimension name to facet by rows. Aligns with Xarray.
col_wrap : int, optional
Number of columns before wrapping. Aligns with Xarray.
size : float, optional
Height (in inches) of each facet. Aligns with Xarray.
aspect : float, optional
Aspect ratio of each facet. Aligns with Xarray.
**kwargs : Any
Keyword arguments passed to :class:SpatialPlot for map features
and projection.
Source code in src/monet_plots/plots/spatial_imshow.py
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 | |
__new__(modelvar, gridobj=None, plotargs=None, **kwargs)
¶
Redirect to SpatialFacetGridPlot if faceting is requested.
This enables a unified interface for both single-panel and multi-panel spatial plots, following Xarray's plotting conventions.
Parameters¶
modelvar : Any
The input data to plot.
gridobj : Any, optional
Object with LAT and LON variables, by default None.
plotargs : dict, optional
Arguments for imshow, by default None.
**kwargs : Any
Additional keyword arguments. If faceting arguments (e.g., col,
row, or col_wrap) are provided, redirects to SpatialFacetGridPlot.
Returns¶
Any An instance of SpatialImshowPlot or SpatialFacetGridPlot.
Source code in src/monet_plots/plots/spatial_imshow.py
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 | |
hvplot(**kwargs)
¶
Generate an interactive spatial plot using hvPlot (Track B).
This method leverages Datashader for high-performance rendering of large geospatial grids.
Parameters¶
**kwargs : Any
Keyword arguments passed to hvplot.quadmesh.
Common options include cmap, title, and alpha.
rasterize=True is used by default for speed.
Returns¶
holoviews.core.layout.Layout The interactive hvPlot object.
Source code in src/monet_plots/plots/spatial_imshow.py
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 | |
plot(**kwargs)
¶
Generate a static publication-quality spatial imshow plot (Track A).
Parameters¶
**kwargs : Any
Keyword arguments passed to matplotlib.pyplot.imshow.
Common options include cmap, vmin, vmax, and alpha.
Map features (e.g., coastlines=True) can also be passed here.
Returns¶
matplotlib.axes.Axes The matplotlib axes object containing the plot.
Source code in src/monet_plots/plots/spatial_imshow.py
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 | |
SpatialPlot
¶
Bases: BasePlot
A base class for creating spatial plots with cartopy.
This class provides a high-level interface for geospatial plots, handling the setup of cartopy axes and the addition of common map features like coastlines, states, and gridlines.
Attributes¶
resolution : str The resolution of the cartopy features (e.g., '50m').
Source code in src/monet_plots/plots/spatial.py
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 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 372 373 374 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 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 | |
__init__(*, projection=ccrs.PlateCarree(), fig=None, ax=None, figsize=None, subplot_kw=None, **kwargs)
¶
Initialize the spatial plot and draw map features.
This constructor sets up the matplotlib Figure and cartopy GeoAxes, and provides a single interface to draw common map features like coastlines and states.
Parameters¶
projection : ccrs.Projection, optional
The cartopy projection for the map, by default ccrs.PlateCarree().
fig : plt.Figure | None, optional
An existing matplotlib Figure object. If None, a new one is
created, by default None.
ax : plt.Axes | None, optional
An existing matplotlib Axes object. If None, a new one is created,
by default None.
figsize : tuple[float, float] | None, optional
Width, height in inches. If not provided, the matplotlib default
will be used.
subplot_kw : dict[str, Any] | None, optional
Keyword arguments passed to fig.add_subplot, by default None.
The 'projection' is added to these keywords automatically.
**kwargs : Any
Keyword arguments for map features, passed to add_features.
Common options include coastlines, states, countries,
ocean, land, lakes, rivers, borders, gridlines,
extent, and resolution.
Attributes¶
fig : plt.Figure The matplotlib Figure object. ax : plt.Axes The matplotlib Axes (or GeoAxes) object. resolution : str The default resolution for cartopy features.
Source code in src/monet_plots/plots/spatial.py
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 | |
add_features(**kwargs)
¶
Add and style cartopy features on the map axes.
This method provides a flexible, data-driven interface to add common
map features. Features can be enabled with a boolean flag (e.g.,
coastlines=True) or styled with a dictionary of keyword arguments
(e.g., states=dict(linewidth=2, edgecolor='red')).
The extent keyword is also supported to set the map boundaries.
Parameters¶
**kwargs : Any
Keyword arguments controlling the features to add and their
styles. Common options include coastlines, states,
countries, ocean, land, lakes, rivers, borders,
and gridlines.
Returns¶
dict[str, Any] A dictionary of the keyword arguments that were not used for adding features. This can be useful for passing remaining arguments to other functions.
Source code in src/monet_plots/plots/spatial.py
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 | |
SpatialTrack
¶
Bases: SpatialPlot
Plot a trajectory from an xarray.DataArray on a map.
This class provides an xarray-native interface for visualizing paths, such as flight trajectories or pollutant tracks, where a variable (e.g., altitude, concentration) is plotted along the path.
It inherits from :class:SpatialPlot to provide the underlying map canvas.
Attributes¶
data : xr.DataArray The trajectory data being plotted. lon_coord : str The name of the longitude coordinate in the DataArray. lat_coord : str The name of the latitude coordinate in the DataArray.
Source code in src/monet_plots/plots/spatial.py
516 517 518 519 520 521 522 523 524 525 526 527 528 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 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 | |
__init__(data, *, lon_coord='lon', lat_coord='lat', **kwargs)
¶
Initialize the SpatialTrack plot.
This constructor validates the input data and sets up the map canvas
by initializing the parent SpatialPlot and adding map features.
Parameters¶
data : xr.DataArray
The input trajectory data. Must be an xarray DataArray with
coordinates for longitude and latitude.
lon_coord : str, optional
Name of the longitude coordinate in the DataArray, by default 'lon'.
lat_coord : str, optional
Name of the latitude coordinate in the DataArray, by default 'lat'.
**kwargs : Any
Keyword arguments passed to :class:SpatialPlot. These control
the map projection, figure size, and cartopy features. For example:
projection=ccrs.LambertConformal(), figsize=(10, 8),
states=True, extent=[-125, -70, 25, 50].
Source code in src/monet_plots/plots/spatial.py
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 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 | |
plot(**kwargs)
¶
Plot the trajectory on the map.
The track is rendered as a scatter plot, where each point is colored
according to the data values.
Parameters¶
**kwargs : Any
Keyword arguments passed to matplotlib.pyplot.scatter.
Common options include cmap, s (size), and alpha.
A transform keyword (e.g., transform=ccrs.PlateCarree())
is highly recommended for geospatial accuracy.
The cmap argument can be a string, a Colormap object, or a
(colormap, norm) tuple from the scaling tools in colorbars.py.
Map features (e.g., coastlines=True) can also be passed here.
Returns¶
plt.Artist
The scatter plot artist created by ax.scatter.
Source code in src/monet_plots/plots/spatial.py
584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 | |
SpreadSkillPlot
¶
Bases: BasePlot
Create a spread-skill plot to evaluate ensemble forecast reliability.
This plot compares the standard deviation of the ensemble spread to the root mean squared error (RMSE) of the ensemble mean. A reliable ensemble should have a spread that is proportional to the forecast error.
Source code in src/monet_plots/plots/ensemble.py
6 7 8 9 10 11 12 13 14 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 | |
__init__(spread, skill, *args, **kwargs)
¶
Initialize the plot with spread and skill data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spread
|
array - like
|
The standard deviation of the ensemble forecast. |
required |
skill
|
array - like
|
The root mean squared error of the ensemble mean. |
required |
Source code in src/monet_plots/plots/ensemble.py
14 15 16 17 18 19 20 21 22 23 24 | |
plot(**kwargs)
¶
Generate the spread-skill plot.
Additional keyword arguments are passed to the scatter plot.
Source code in src/monet_plots/plots/ensemble.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | |
StickPlot
¶
Bases: BasePlot
Vertical stick plot.
Source code in src/monet_plots/plots/profile.py
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 | |
__init__(u, v, y, *args, **kwargs)
¶
Initialize the stick plot. Args: u (np.ndarray, pd.Series, xr.DataArray): U-component of the vector. v (np.ndarray, pd.Series, xr.DataArray): V-component of the vector. y (np.ndarray, pd.Series, xr.DataArray): Vertical coordinate. **kwargs: Additional keyword arguments passed to BasePlot.
Source code in src/monet_plots/plots/profile.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
plot(**kwargs)
¶
Parameters¶
**kwargs
Keyword arguments passed to matplotlib.pyplot.quiver.
Source code in src/monet_plots/plots/profile.py
107 108 109 110 111 112 113 114 115 116 117 118 119 | |
TaylorDiagramPlot
¶
Bases: BasePlot
Create a DataFrame-based Taylor diagram.
A convenience wrapper for easily creating Taylor diagrams from DataFrames.
Source code in src/monet_plots/plots/taylor_diagram.py
11 12 13 14 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 | |
__init__(df, col1='obs', col2='model', label1='OBS', scale=1.5, dia=None, *args, **kwargs)
¶
Initialize the plot with data and diagram settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
(DataFrame, ndarray, Dataset, DataArray)
|
DataFrame with observation and model data. |
required |
col1
|
str
|
Column name for observations. |
'obs'
|
col2
|
str or list
|
Column name(s) for model predictions. |
'model'
|
label1
|
str
|
Label for observations. |
'OBS'
|
scale
|
float
|
Scale factor for diagram. |
1.5
|
dia
|
TaylorDiagram
|
Existing diagram to add to. |
None
|
Source code in src/monet_plots/plots/taylor_diagram.py
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 | |
plot(**kwargs)
¶
Generate the Taylor diagram.
Source code in src/monet_plots/plots/taylor_diagram.py
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 | |
TimeSeriesPlot
¶
Bases: BasePlot
Create a timeseries plot with shaded error bounds.
This function groups the data by time, plots the mean values, and adds shading for ±1 standard deviation around the mean.
Source code in src/monet_plots/plots/timeseries.py
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 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 | |
__init__(df, x='time', y='obs', plotargs={}, fillargs=None, title='', ylabel=None, label=None, *args, **kwargs)
¶
Initialize the plot with data and plot settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
(DataFrame, ndarray, Dataset, DataArray)
|
DataFrame with the data to plot. |
required |
x
|
str
|
Column name for the x-axis (time). |
'time'
|
y
|
str
|
Column name for the y-axis (values). |
'obs'
|
plotargs
|
dict
|
Arguments for the plot. |
{}
|
fillargs
|
dict
|
Arguments for fill_between. |
None
|
title
|
str
|
Title for the plot. |
''
|
ylabel
|
str
|
Y-axis label. |
None
|
label
|
str
|
Label for the plotted line. |
None
|
*args, **kwargs
|
Arguments passed to BasePlot. |
required |
Source code in src/monet_plots/plots/timeseries.py
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 | |
plot(**kwargs)
¶
Generate the timeseries plot.
Parameters¶
**kwargs : Any Overrides for plot settings (x, y, title, ylabel, label, etc.).
Returns¶
plt.Axes The matplotlib axes object containing the plot.
Examples¶
plot = TimeSeriesPlot(df, x='time', y='obs') ax = plot.plot(title='Observation Over Time')
Source code in src/monet_plots/plots/timeseries.py
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 | |
TrajectoryPlot
¶
Bases: BasePlot
Plot a trajectory on a map and a timeseries of a variable.
Source code in src/monet_plots/plots/trajectory.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 | |
__init__(longitude, latitude, data, time, ts_data, *args, **kwargs)
¶
Initialize the trajectory plot. Args: longitude: Longitude values for the spatial track. latitude: Latitude values for the spatial track. data: Data to use for coloring the track. time: Time values for the timeseries or a DataFrame. ts_data: Data for the timeseries or column name if time is a DataFrame. args: Additional positional arguments. *kwargs: Additional keyword arguments.
Source code in src/monet_plots/plots/trajectory.py
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 | |
plot(**kwargs)
¶
Plot the trajectory and timeseries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Keyword arguments passed to the plot methods. |
{}
|
Source code in src/monet_plots/plots/trajectory.py
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 | |
VerticalBoxPlot
¶
Bases: BasePlot
Vertical box plot.
Source code in src/monet_plots/plots/profile.py
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 | |
__init__(data, y, thresholds, *args, **kwargs)
¶
Initialize the vertical box plot. Args: data (np.ndarray, pd.Series, xr.DataArray): Data to plot. y (np.ndarray, pd.Series, xr.DataArray): Vertical coordinate. thresholds (list): List of thresholds to bin the data. **kwargs: Additional keyword arguments passed to BasePlot.
Source code in src/monet_plots/plots/profile.py
125 126 127 128 129 130 131 132 133 134 135 136 137 | |
plot(**kwargs)
¶
Parameters¶
**kwargs
Keyword arguments passed to matplotlib.pyplot.boxplot.
Source code in src/monet_plots/plots/profile.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
VerticalSlice
¶
Bases: ProfilePlot
Vertical cross-section plot.
Source code in src/monet_plots/plots/profile.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
__init__(*args, **kwargs)
¶
Initialize the vertical slice plot.
Source code in src/monet_plots/plots/profile.py
68 69 70 71 72 | |
plot(**kwargs)
¶
Parameters¶
**kwargs
Keyword arguments passed to matplotlib.pyplot.contourf.
Source code in src/monet_plots/plots/profile.py
74 75 76 77 78 79 80 81 82 83 84 85 86 | |
WindBarbsPlot
¶
Bases: SpatialPlot
Create a barbs plot of wind on a map.
This plot shows wind speed and direction using barbs.
Source code in src/monet_plots/plots/wind_barbs.py
12 13 14 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 | |
__init__(ws, wdir, gridobj, *args, **kwargs)
¶
Initialize the plot with data and map projection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ws
|
(ndarray, DataFrame, Series, DataArray)
|
2D array of wind speeds. |
required |
wdir
|
(ndarray, DataFrame, Series, DataArray)
|
2D array of wind directions. |
required |
gridobj
|
object
|
Object with LAT and LON variables. |
required |
**kwargs
|
Keyword arguments passed to SpatialPlot for projection and features. |
{}
|
Source code in src/monet_plots/plots/wind_barbs.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
plot(**kwargs)
¶
Generate the wind barbs plot.
Source code in src/monet_plots/plots/wind_barbs.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
WindQuiverPlot
¶
Bases: SpatialPlot
Create a quiver plot of wind vectors on a map.
This plot shows wind speed and direction using arrows.
Source code in src/monet_plots/plots/wind_quiver.py
12 13 14 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 | |
__init__(ws, wdir, gridobj, *args, **kwargs)
¶
Initialize the plot with data and map projection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ws
|
(ndarray, DataFrame, Series, DataArray)
|
2D array of wind speeds. |
required |
wdir
|
(ndarray, DataFrame, Series, DataArray)
|
2D array of wind directions. |
required |
gridobj
|
object
|
Object with LAT and LON variables. |
required |
**kwargs
|
Keyword arguments passed to SpatialPlot for projection and features. |
{}
|
Source code in src/monet_plots/plots/wind_quiver.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
plot(**kwargs)
¶
Generate the wind quiver plot.
Source code in src/monet_plots/plots/wind_quiver.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
get_available_styles()
¶
Returns a list of available style context names.
Returns¶
list[str] List of style names.
Source code in src/monet_plots/style.py
198 199 200 201 202 203 204 205 206 207 | |
get_style_setting(key, default=None)
¶
Retrieves a style setting from the currently active style. Looks in both standard rcParams and custom style settings.
Parameters¶
key : str The name of the style setting. default : Any, optional The default value if the key is not found, by default None.
Returns¶
Any The style setting value.
Source code in src/monet_plots/style.py
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | |
set_style(context='wiley')
¶
Set the plotting style based on a predefined context.
Parameters¶
context : str, optional The name of the style context to apply. Available contexts: "wiley", "presentation", "paper", "web", "pivotal_weather", "default". Defaults to "wiley".
Raises¶
ValueError If an unknown context name is provided.
Source code in src/monet_plots/style.py
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 | |
Taylor diagram (Taylor, 2001) implementation.
A Taylor diagram is a graphical representation of how well a model simulates an observed pattern. It provides a way to summarize multiple aspects of model performance, including: - Correlation coefficient - Root-mean-square (RMS) difference - The standard deviation ratio
Reference: Taylor, K.E., 2001. Summarizing multiple aspects of model performance in a single diagram. Journal of Geophysical Research, 106(D7), 7183-7192.
TaylorDiagram
¶
:no-index:
Taylor diagram for visualizing model performance metrics.
The Taylor diagram displays multiple statistical metrics in a single plot: - The radial distance from the origin represents the standard deviation - The azimuthal position represents the correlation coefficient - The distance from the reference point represents the root-mean-square (RMS) difference
This class creates a Taylor diagram in a polar plot, where: - r = standard deviation - θ = arccos(correlation coefficient)
This provides a comprehensive view of how well a model pattern matches observations.
Source code in src/monet_plots/taylordiagram.py
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 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 | |
samples
property
¶
Property to provide compatibility with tests expecting 'samples' attribute.
__init__(refstd, scale=1.5, fig=None, rect=111, label='_')
¶
Initialize the Taylor diagram.
Parameters¶
refstd : float The reference standard deviation (e.g., from observations or a reference model) that other models will be compared against. scale : float, default 1.5 The maximum standard deviation shown on the plot, as a multiple of refstd. For example, if refstd=2 and scale=1.5, the maximum standard deviation displayed will be 3.0. fig : matplotlib.figure.Figure, optional Figure to use. If None, a new figure will be created. rect : int or tuple, default 111 Subplot specification (nrows, ncols, index) or 3-digit integer where the digits represent nrows, ncols, and index in order. label : str, default "_" Label for the reference point. An underscore prefix makes the label not appear in the legend.
Source code in src/monet_plots/taylordiagram.py
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 | |
add_contours(levels=5, **kwargs)
¶
Add constant RMS difference contours to the Taylor diagram.
Parameters¶
levels : int or array-like, default 5 If an integer, it defines the number of equally-spaced contour levels. If array-like, it explicitly defines the contour levels. **kwargs Additional keyword arguments passed to matplotlib's contour function. Common options include 'colors', 'linewidths', and 'linestyles'.
Returns¶
matplotlib.contour.QuadContourSet The contour set created by the function.
Notes¶
These contours represent lines of constant RMS difference between the reference and sample datasets. They help visualize the combined effect of differences in standard deviation and correlation.
Source code in src/monet_plots/taylordiagram.py
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 | |
add_sample(stddev, corrcoef, *args, **kwargs)
¶
Add a sample point to the Taylor diagram.
Parameters¶
stddev : float Standard deviation of the sample to add. corrcoef : float Correlation coefficient between the sample and reference (-1 to 1). args Additional positional arguments passed to matplotlib's plot function. *kwargs Additional keyword arguments passed to matplotlib's plot function. Common options include 'marker', 'markersize', 'color', and 'label'.
Returns¶
matplotlib.lines.Line2D The line object representing the sample in the plot.
Notes¶
Points closer to the reference point indicate better agreement with the reference dataset.
Source code in src/monet_plots/taylordiagram.py
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 | |
split_by_threshold(data_list, alt_list, threshold_list)
¶
Splits data into bins based on altitude thresholds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_list
|
list
|
List of data values. |
required |
alt_list
|
list
|
List of altitude values corresponding to the data. |
required |
threshold_list
|
list
|
List of altitude thresholds to bin the data. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
A list of arrays, where each array contains the data values within an altitude bin. |
Source code in src/monet_plots/tools.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | |
uv2wsdir(u, v)
¶
Converts u and v components to wind speed and direction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u
|
ndarray
|
The u component of the wind. |
required |
v
|
ndarray
|
The v component of the wind. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
A tuple containing the wind speed and direction. |
Source code in src/monet_plots/tools.py
44 45 46 47 48 49 50 51 52 53 54 55 56 | |
wsdir2uv(ws, wdir)
¶
Converts wind speed and direction to u and v components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ws
|
ndarray
|
The wind speed. |
required |
wdir
|
ndarray
|
The wind direction. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
A tuple containing the u and v components of the wind. |
Source code in src/monet_plots/tools.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |