Plotting¶
Bathymetry¶
bathy.plot_bathy(data, contours=None, cmap=None, mask_land=True, **kwargs)
¶
Plot bathymetry elevation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataArray
|
Elevation data |
required |
contours
|
int or list[float]
|
Number of contour levels or specific levels (in metres) |
None
|
cmap
|
str or Colormap
|
Colormap. Defaults to cmocean 'deep_r'. |
None
|
mask_land
|
bool
|
If True, mask positive elevations (land). |
True
|
**kwargs
|
Additional arguments passed to xarray plot |
{}
|
Returns:
| Type | Description |
|---|---|
tuple[Figure, Axes]
|
Matplotlib figure and axes for further customisation. |
Source code in src/bathy/plot.py
bathy.plot_hillshade(data, azimuth=315, altitude=45, contours=None, **kwargs)
¶
Create hillshade visualisation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataArray
|
Elevation data |
required |
azimuth
|
float
|
Light source azimuth in degrees |
315
|
altitude
|
float
|
Light source altitude in degrees |
45
|
contours
|
int or list[float]
|
Contour levels |
None
|
**kwargs
|
Additional arguments passed to imshow |
{}
|
Returns:
| Type | Description |
|---|---|
tuple[Figure, Axes]
|
Matplotlib figure and axes for further customisation. |
Source code in src/bathy/plot.py
bathy.plot_slope(data, contours=None, vmax=None, **kwargs)
¶
Plot seafloor slope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataArray
|
Elevation data |
required |
contours
|
int or list[float]
|
Contour levels |
None
|
vmax
|
float
|
Maximum slope value for colour scale. |
None
|
**kwargs
|
Additional arguments passed to imshow |
{}
|
Returns:
| Type | Description |
|---|---|
tuple[Figure, Axes]
|
Matplotlib figure and axes for further customisation. |
Source code in src/bathy/plot.py
bathy.plot_curvature(data, contours=None, **kwargs)
¶
Plot seafloor curvature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataArray
|
Elevation data |
required |
contours
|
int or list[float]
|
Contour levels |
None
|
**kwargs
|
Additional arguments passed to imshow |
{}
|
Returns:
| Type | Description |
|---|---|
tuple[Figure, Axes]
|
Matplotlib figure and axes for further customisation. |
Source code in src/bathy/plot.py
bathy.plot_aspect(data, contours=None, **kwargs)
¶
Plot seafloor aspect.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataArray
|
Elevation data |
required |
contours
|
int or list[float]
|
Contour levels |
None
|
**kwargs
|
Additional arguments passed to imshow |
{}
|
Returns:
| Type | Description |
|---|---|
tuple[Figure, Axes]
|
Matplotlib figure and axes for further customisation. |
Source code in src/bathy/plot.py
bathy.plot_bpi(data, radius_km=1.0, contours=None, **kwargs)
¶
Plot Bathymetric Position Index (BPI).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataArray
|
Elevation data |
required |
radius_km
|
float
|
Neighbourhood radius in kilometres |
1.0
|
contours
|
int or list[float]
|
Contour levels |
None
|
**kwargs
|
Additional arguments passed to imshow |
{}
|
Returns:
| Type | Description |
|---|---|
tuple[Figure, Axes]
|
Matplotlib figure and axes for further customisation. |
Source code in src/bathy/plot.py
bathy.plot_rugosity(data, radius_km=1.0, contours=None, vmax=None, **kwargs)
¶
Plot Vector Ruggedness Measure (VRM).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataArray
|
Elevation data |
required |
radius_km
|
float
|
Neighbourhood radius in kilometres |
1.0
|
contours
|
int or list[float]
|
Contour levels |
None
|
vmax
|
float
|
Maximum VRM value for colour scale. |
None
|
**kwargs
|
Additional arguments passed to imshow |
{}
|
Returns:
| Type | Description |
|---|---|
tuple[Figure, Axes]
|
Matplotlib figure and axes for further customisation. |
Source code in src/bathy/plot.py
bathy.plot_geomorphons(data, lookup_km=2.0, flatness_threshold=1.0, **kwargs)
¶
Plot seafloor morphology using geomorphons.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataArray
|
Elevation data |
required |
lookup_km
|
float
|
Lookup distance in kilometres. |
2.0
|
flatness_threshold
|
float
|
Flatness angle threshold in degrees. |
1.0
|
**kwargs
|
Additional arguments passed to imshow. |
{}
|
Returns:
| Type | Description |
|---|---|
tuple[Figure, Axes]
|
Matplotlib figure and axes for further customisation. |
Examples:
Source code in src/bathy/plot.py
bathy.plot_overview(data, bpi_radius_km=1.0, rugosity_radius_km=1.0, geomorphons_lookup_km=2.0, label_prefix=None)
¶
Plot key bathymetric metrics as subplot overview.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataArray
|
Elevation data |
required |
bpi_radius_km
|
float
|
Neighbourhood radius for BPI in kilometres. |
1.0
|
rugosity_radius_km
|
float
|
Neighbourhood radius for rugosity in kilometres. |
1.0
|
geomorphons_lookup_km
|
float
|
Lookup distance for geomorphons in kilometres. |
2.0
|
label_prefix
|
list[str] | None
|
Optional list of 8 prefix strings for panel titles. |
None
|
Examples:
Returns¶
tuple[Figure, np.ndarray] Matplotlib figure and array of axes for further customisation.
Examples:
Source code in src/bathy/plot.py
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 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 | |
Distribution¶
bathy.plot_depth_zones(data, zones=None, labels=None, contours=None, **kwargs)
¶
Plot bathymetry color-coded by depth zones.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataArray
|
Elevation data |
required |
zones
|
list[float]
|
Depth boundaries (default: [0, -200, -1000, -4000]) |
None
|
labels
|
list[str]
|
Zone labels (default: ['Shelf', 'Slope', 'Abyss', 'Deep']) |
None
|
contours
|
int or list[float]
|
Contour levels |
None
|
**kwargs
|
Additional arguments passed to imshow |
{}
|
Returns:
| Type | Description |
|---|---|
tuple[Figure, Axes]
|
Matplotlib figure and axes for further customisation. |
Source code in src/bathy/plot.py
bathy.plot_histogram(data, bins=50, **kwargs)
¶
Plot histogram of elevation values.
Returns:
| Type | Description |
|---|---|
tuple[Figure, Axes]
|
Matplotlib figure and axes for further customisation. |
Source code in src/bathy/plot.py
bathy.plot_hypsometric_curve(data, bins=100, **kwargs)
¶
Plot the hypsometric curve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataArray
|
Elevation data |
required |
bins
|
int
|
Number of elevation bins |
100
|
**kwargs
|
Additional arguments passed to plt.plot |
{}
|
Returns:
| Type | Description |
|---|---|
tuple[Figure, Axes]
|
Matplotlib figure and axes for further customisation. |
Examples:
Source code in src/bathy/plot.py
Interactive¶
bathy.plot_interactive(data, overlays=None, cmap=None, opacity=0.7, mask_land=True, tiles='CartoDB positron')
¶
Display bathymetry on an interactive Leaflet map.
Uses folium to render an interactive map overlay. Additional
analysis layers (slope, aspect, etc.) can be added via overlays
and toggled with the layer control.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataArray
|
Elevation data. |
required |
overlays
|
dict[str, DataArray]
|
Extra layers to display, e.g. |
None
|
cmap
|
str or Colormap
|
Colormap for the bathymetry layer. Defaults to cmocean 'deep_r'. |
None
|
opacity
|
float
|
Overlay opacity for valid (ocean) pixels. |
0.7
|
mask_land
|
bool
|
If True, mask positive elevations as transparent. |
True
|
tiles
|
str
|
Base tile layer name. |
'CartoDB positron'
|
Returns:
| Type | Description |
|---|---|
Map
|
Interactive map. Renders in Jupyter; call |
Examples:
>>> m = bathy.plot_interactive(data)
>>> m = bathy.plot_interactive(data, overlays={"Slope": bathy.slope(data)})
>>> m.save("my_map.html")
Source code in src/bathy/plot.py
871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 | |
3D¶
bathy.plot_surface3d(data, stride=10, vertical_exaggeration=50.0, smooth=None, elev=30, azim=-60, **kwargs)
¶
Create static 3D surface plot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataArray
|
Elevation data |
required |
stride
|
int
|
Stride for downsampling (every Nth point) |
10
|
vertical_exaggeration
|
float
|
Factor to exaggerate the vertical scale. |
50.0
|
smooth
|
int
|
Uniform filter kernel size for smoothing. |
None
|
elev
|
float
|
Elevation viewing angle in degrees. |
30
|
azim
|
float
|
Azimuth viewing angle in degrees. |
-60
|
**kwargs
|
Additional arguments passed to plot_surface |
{}
|
Returns:
| Type | Description |
|---|---|
tuple[Figure, Axes]
|
Matplotlib figure and axes for further customisation. |
Source code in src/bathy/plot.py
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 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 | |
Profile¶
bathy.plot_profile(profile, show_map=False, smooth=None, normalize=False, ensure_descending=False, cmap=cmo.deep_r, bathymetry_data=None, y_pad=0.05, **kwargs)
¶
Plot the bathymetric profile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profile
|
Profile
|
|
required |
show_map
|
bool
|
If True, show map with profile line. Requires bathymetry_data. |
False
|
smooth
|
float
|
Gaussian smoothing sigma. |
None
|
normalize
|
bool
|
If True, normalize elevation and distance to 0-1. |
False
|
ensure_descending
|
bool
|
If True, orient profile to descend from higher to lower elevation. |
False
|
bathymetry_data
|
DataArray
|
Background data for map view (required when show_map=True). |
None
|
y_pad
|
float
|
Fractional padding added above and below the elevation range. Defaults to 0.05 (5%). |
0.05
|
**kwargs
|
Additional arguments passed to matplotlib plot() |
{}
|
Returns:
| Type | Description |
|---|---|
tuple[Figure, list[Axes]]
|
Figure and list of axes (one element without map, two with map). |
Source code in src/bathy/profile_plot.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 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 | |
bathy.plot_profiles(profiles, show_map=False, normalize=False, ensure_descending=False, bathymetry_data=None, cmap=cmo.deep_r, **kwargs)
¶
Plot multiple profiles on the same axes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profiles
|
Profile or list[Profile]
|
|
required |
show_map
|
bool
|
If True, show map with profile lines alongside the profile plot. Requires bathymetry_data. |
False
|
normalize
|
bool
|
If True, normalize each profile's elevation and distance to 0-1. |
False
|
ensure_descending
|
bool
|
If True, orient profiles to descend from higher to lower elevation. |
False
|
bathymetry_data
|
DataArray
|
Background data for map view. |
None
|
**kwargs
|
Additional arguments passed to matplotlib plot() |
{}
|
Returns:
| Type | Description |
|---|---|
tuple[Figure, list[Axes]]
|
Figure and list of axes (one element without map, two with map). |
Examples:
>>> from bathy.profile_plot import plot_profiles
>>> prof1 = extract_profile(data, start=(-8, 52), end=(-2, 58), name="Profile 1")
>>> prof2 = extract_profile(data, start=(-8, 53), end=(-2, 59), name="Profile 2")
>>> plot_profiles([prof1, prof2])
Source code in src/bathy/profile_plot.py
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 | |
bathy.plot_profiles_map(profiles, bathymetry_data=None, main_profile=None, cmap=cmo.deep_r, **kwargs)
¶
Plot profile locations on a map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profiles
|
Profile or list[Profile]
|
|
required |
bathymetry_data
|
DataArray
|
Background bathymetry data. |
None
|
main_profile
|
Profile
|
Main profile to highlight. |
None
|
**kwargs
|
Additional arguments passed to matplotlib plot() |
{}
|
Returns:
| Type | Description |
|---|---|
(Figure, Axes)
|
|
Examples:
>>> from bathy.profile_plot import plot_profiles_map
>>> plot_profiles_map([prof1, prof2], bathymetry_data=data)
Source code in src/bathy/profile_plot.py
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 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 | |
bathy.plot_profiles_grid(profiles, cols=2, figsize=None, main_profile=None, smooth=None, normalize=False, ensure_descending=False, y_pad=0.05, **kwargs)
¶
Plot multiple profiles in a grid of subplots.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profiles
|
Profile or list[Profile]
|
|
required |
cols
|
int
|
Number of columns in the grid (default: 2) |
2
|
figsize
|
tuple[float, float]
|
Figure size. Calculated if None. |
None
|
main_profile
|
Profile
|
Main profile; marks intersection with each cross-section. |
None
|
smooth
|
float
|
Gaussian smoothing sigma. |
None
|
normalize
|
bool
|
If True, normalize each profile's elevation and distance to 0-1. |
False
|
ensure_descending
|
bool
|
If True, orient profiles to descend from higher to lower elevation. |
False
|
y_pad
|
float
|
Fractional padding added above and below the elevation range. Defaults to 0.05 (5%). |
0.05
|
**kwargs
|
Additional arguments passed to matplotlib plot() |
{}
|
Returns:
| Type | Description |
|---|---|
(Figure, ndarray)
|
|
Examples:
>>> from bathy.profile_plot import plot_profiles_grid
>>> profiles = profiles_from_file(data, "canyons.shp")
>>> plot_profiles_grid(profiles[:10])
Source code in src/bathy/profile_plot.py
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 | |
bathy.plot_gradient(profile, **kwargs)
¶
Plot the gradient (derivative) along the profile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profile
|
Profile
|
|
required |
**kwargs
|
Additional arguments passed to plot |
{}
|
Returns:
| Type | Description |
|---|---|
tuple[Figure, list[Axes]]
|
Figure and list containing the single gradient axes. |
Source code in src/bathy/profile_plot.py
bathy.plot_knickpoints(profile, knickpoints_df=None, threshold=None, smooth=None, **kwargs)
¶
Plot profile with knickpoints marked.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profile
|
Profile
|
|
required |
knickpoints_df
|
DataFrame
|
Knickpoint data from knickpoints(). Detected if None. |
None
|
threshold
|
float
|
Minimum slope break for detection (ignored if knickpoints_df provided). |
None
|
smooth
|
float
|
Smoothing sigma (ignored if knickpoints_df provided). |
None
|
**kwargs
|
Additional arguments passed to plot_profile |
{}
|
Returns:
| Type | Description |
|---|---|
tuple[Figure, list[Axes]]
|
Figure and list of axes. |
Source code in src/bathy/profile_plot.py
bathy.plot_canyons(profile, canyons, **kwargs)
¶
Plot profile with canyons marked.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profile
|
Profile
|
|
required |
canyons
|
DataFrame
|
Canyon data from |
required |
**kwargs
|
Additional arguments passed to plot_profile() |
{}
|
Returns:
| Type | Description |
|---|---|
tuple[Figure, list[Axes]]
|
Figure and list of axes. |