Plotting Module#
The Plotting module provides functions for generating visualizations of bank lines, erosion results, and other data in the D-FAST Bank Erosion software.
Overview#
The Plotting module contains functions for creating various types of plots and visualizations that help users understand the results of bank line detection and erosion calculations. These visualizations include maps of bank lines, erosion profiles, and time series of erosion volumes.
Components#
The Plotting module consists of the following components:
Plotting Functions#
dfastbe.plotting
#
Copyright (C) 2020 Stichting Deltares.
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation version 2.1.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, see http://www.gnu.org/licenses/.
contact: delft3d.support@deltares.nl Stichting Deltares P.O. Box 177 2600 MH Delft, The Netherlands
All indications and logos of, and references to, "Delft3D" and "Deltares" are registered trademarks of Stichting Deltares, and remain the property of Stichting Deltares. All rights reserved.
INFORMATION This file is part of D-FAST Bank Erosion: https://github.com/Deltares/D-FAST_Bank_Erosion
chainage_markers(xykm: numpy.ndarray, ax: matplotlib.axes.Axes, ndec: int = 1, scale: float = 1000) -> None
#
Add markers indicating the river chainage to a plot.
Arguments#
xykm : numpy.ndarray Array containing the x, y, and chainage; unit m for x and y, km for chainage. ax : matplotlib.axes.Axes Axes object in which to add the markers. ndec : int Number of decimals used for marks. scale: float Indicates whether the axes are in m (1) or km (1000).
Source code in src/dfastbe/plotting.py
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 |
|
get_colors(cmap_name: str, n: int) -> List[Tuple[float, float, float]]
#
Obtain N colors from the specified colormap.
Arguments#
cmap_name : str Name of the color map. n : int Number of colors to be returned.
Returns#
clrcyc : List[Tuple[float, float, float]] List of colour tuplets.
Source code in src/dfastbe/plotting.py
1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 |
|
plot1_waterdepth_and_banklines(bbox: Tuple[float, float, float, float], xykm: numpy.ndarray, banklines: geopandas.geodataframe.GeoDataFrame, fn: numpy.ndarray, nnodes: numpy.ndarray, xn: numpy.ndarray, yn: numpy.ndarray, h: numpy.ndarray, hmax: float, xlabel_txt: str, ylabel_txt: str, title_txt: str, waterdepth_txt: str) -> [matplotlib.figure.Figure, matplotlib.axes.Axes]
#
Create the bank erosion plot with water depths and initial bank lines.
Tuple[float, float, float, float]
Tuple containing boundary limits (xmin, ymin, xmax, ymax); unit m.
xykm : numpy.ndarray Array containing the x, y, and chainage; unit m for x and y, km for chainage. banklines : geopandas.geodataframe.GeoDataFrame Pandas object containing the bank lines.
numpy.ndarray
N x M array listing the nodes (max M) per face (total N) of the mesh.
nnodes : numpy.ndarray Number of nodes per face (max M). xn : numpy.ndarray X-coordinates of the mesh nodes. yn : numpy.ndarray Y-coordinates of the mesh nodes. h : numpy.ndarray Array of water depth values. hmax : float Water depth value to be used as upper limit for coloring. xlabel_txt : str Label for the x-axis. ylabel_txt : str Label for the y-axis. title_txt : str Label for the axes title. waterdepth_txt : str Label for the color bar.
Results#
fig : matplotlib.figure.Figure Figure object. ax : matplotlib.axes.Axes Axes object.
Source code in src/dfastbe/plotting.py
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 |
|
plot2_eroded_distance_and_equilibrium(bbox: Tuple[float, float, float, float], xykm: numpy.ndarray, bank_crds: List[numpy.ndarray], dn_tot: List[numpy.ndarray], to_right: List[bool], dnav: numpy.ndarray, xy_eq: List[numpy.ndarray], xe: numpy.ndarray, ye: numpy.ndarray, xlabel_txt: str, ylabel_txt: str, title_txt: str, erosion_txt: str, eroclr_txt: str, eqbank_txt: str) -> [matplotlib.figure.Figure, matplotlib.axes.Axes]
#
Create the bank erosion plot with predicted bank line shift and equilibrium bank line.
Arguments#
bbox : Tuple[float, float, float, float] Tuple containing boundary limits (xmin, ymin, xmax, ymax); unit m. xykm : numpy.ndarray Array containing the x, y, and chainage; unit m for x and y, km for chainage. bank_crds : List[numpy.ndarray] List of N arrays containing the x- and y-coordinates of the original bank lines. dn_tot : List[numpy.ndarray] List of N arrays containing the total erosion distance values. to_right : List[bool] List of N booleans indicating whether the bank is on the right. dnav : numpy.ndarray Array of N average erosion distance values. xy_eq : List[numpy.ndarray] List of N arrays containing the x- and y-coordinates of the equilibrium bank line. xe : numpy.ndarray M x 2 array of begin/end x-coordinates of mesh edges. ye : numpy.ndarray M x 2 array of begin/end y-coordinates of mesh edges. xlabel_txt : str Label for the x-axis. ylabel_txt : str Label for the y-axis. title_txt : str Label for the axes title. erosion_txt : str Label for the shaded eroded area. eroclr_txt : str Label for the color bar. eqbank_txt : str Label for the equilibrium bank position.
Results#
fig : matplotlib.figure.Figure Figure object. ax : matplotlib.axes.Axes Axes object.
Source code in src/dfastbe/plotting.py
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 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 |
|
plot3_eroded_volume(km_mid: numpy.ndarray, km_step: float, chainage_txt: str, erosion_volume: List[List[numpy.ndarray]], ylabel_txt: str, title_txt: str, qlabel: str, banklabel: str) -> [matplotlib.figure.Figure, matplotlib.axes.Axes]
#
Create the bank erosion plot with total eroded volume subdivided per discharge level.
Arguments#
km_mid : numpy.ndarray Array containing the mid points for the chainage bins. km_step : float Bin width. chainage_txt : str Label for the horizontal chainage axes. erosion_volume : List[List[numpy.ndarray]] List of nQ lists of N arrays containing the total erosion distance values ylabel_txt : str Label for the vertical erosion volume axes. title_txt : str Label for axes title. qlabel : str Label for discharge level. banklabel : str Label for bank id.
Results#
fig : matplotlib.figure.Figure Figure object. ax : matplotlib.axes.Axes Axes object.
Source code in src/dfastbe/plotting.py
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 |
|
plot3_eroded_volume_subdivided_1(km_mid: numpy.ndarray, km_step: float, chainage_txt: str, erosion_volume: List[List[numpy.ndarray]], ylabel_txt: str, title_txt: str, qlabel: str) -> [matplotlib.figure.Figure, matplotlib.axes.Axes]
#
Create the bank erosion plot with total eroded volume subdivided per discharge level.
Arguments#
km_mid : numpy.ndarray Array containing the mid points for the chainage bins. km_step : float Bin width. chainage_txt : str Label for the horizontal chainage axes. erosion_volume : List[List[numpy.ndarray]] List of nQ lists of N arrays containing the total erosion distance values ylabel_txt : str Label for the vertical erosion volume axes. title_txt : str Label for axes title. qlabel : str Label for discharge level.
Results#
fig : matplotlib.figure.Figure Figure object. ax : matplotlib.axes.Axes Axes object.
Source code in src/dfastbe/plotting.py
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 |
|
plot3_eroded_volume_subdivided_2(km_mid: numpy.ndarray, km_step: float, chainage_txt: str, erosion_volume: List[List[numpy.ndarray]], ylabel_txt: str, title_txt: str, banklabel: str) -> [matplotlib.figure.Figure, matplotlib.axes.Axes]
#
Create the bank erosion plot with total eroded volume subdivided per bank.
Arguments#
km_mid : numpy.ndarray Array containing the mid points for the chainage bins. km_step : float Bin width. chainage_txt : str Label for the horizontal chainage axes. erosion_volume : List[List[numpy.ndarray]] List of nQ lists of N arrays containing the total erosion distance values ylabel_txt : str Label for the vertical erosion volume axes. title_txt : str Label for axes title. banklabel : str Label for bank id.
Results#
fig : matplotlib.figure.Figure Figure object. ax : matplotlib.axes.Axes Axes object.
Source code in src/dfastbe/plotting.py
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 |
|
plot3_stacked_per_bank(ax: matplotlib.axes.Axes, km_mid: numpy.ndarray, km_step: float, erosion_volume: List[List[numpy.ndarray]], banklabel: str, wfrac: float) -> None
#
Add a stacked plot of bank erosion with total eroded volume subdivided per bank to the selected axes.
Arguments#
fig : matplotlib.figure.Figure Figure object. ax : matplotlib.axes.Axes Axes object. km_mid : numpy.ndarray Array containing the mid points for the chainage bins. km_step : float Bin width. erosion_volume : List[List[numpy.ndarray]] List of nQ lists of N arrays containing the total erosion distance values banklabel : str Label for bank id. wfrac : float Width fraction for the stacked column.
Results#
None
Source code in src/dfastbe/plotting.py
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 |
|
plot3_stacked_per_discharge(ax: matplotlib.axes.Axes, km_mid: numpy.ndarray, km_step: float, erosion_volume: List[List[numpy.ndarray]], qlabel: str, wfrac: float) -> None
#
Add a stacked plot of bank erosion with total eroded volume subdivided per discharge level to the selected axes.
Arguments#
fig : matplotlib.figure.Figure Figure object. ax : matplotlib.axes.Axes Axes object. km_mid : numpy.ndarray Array containing the mid points for the chainage bins. km_step : float Bin width. erosion_volume : List[List[numpy.ndarray]] List of nQ lists of N arrays containing the total erosion distance values qlabel : str Label for discharge level. wfrac : float Width fraction for the stacked column.
Results#
None
Source code in src/dfastbe/plotting.py
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 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 |
|
plot4_eroded_volume_eq(km_mid: numpy.ndarray, km_step: float, chainage_txt: str, vol_eq: numpy.ndarray, ylabel_txt: str, title_txt: str) -> [matplotlib.figure.Figure, matplotlib.axes.Axes]
#
Create the bank erosion plot with equilibrium eroded volume.
Arguments#
km_mid : numpy.ndarray Array containing the mid points for the chainage bins. km_step : float Bin width. chainage_txt : str Label for the horizontal chainage axes. vol_eq : numpy.ndarray Array containing the equilibrium eroded volume per bin. ylabel_txt : str Label for the vertical erosion volume axes. title_txt : str Label for axes title.
Results#
fig : matplotlib.figure.Figure Figure object. ax : matplotlib.axes.Axes Axes object.
Source code in src/dfastbe/plotting.py
817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 |
|
plot5series_waterlevels_per_bank(bank_km_mid: List[numpy.ndarray], chainage_txt: str, waterlevel: List[List[numpy.ndarray]], shipwavemax: List[List[numpy.ndarray]], shipwavemin: List[List[numpy.ndarray]], waterlevelq_txt: str, avg_waterlevel_txt: str, shipwave_txt: str, bankheight: List[numpy.ndarray], bankheight_txt: str, bankprotect: List[numpy.ndarray], bankprotect_txt: str, elevation_txt: str, title_txt: str, elevation_unit: str) -> [List[matplotlib.figure.Figure], List[matplotlib.axes.Axes]]
#
Create the bank erosion plots with water levels, bank height and bank protection height along each bank.
Arguments#
bank_km_mid : List[numpy.ndarray] List of arrays containing the chainage values per bank (segment) [km]. chainage_txt : str Label for the horizontal chainage axes. waterlevel : List[List[numpy.ndarray]] List of arrays containing the water levels per bank (point) [elevation_unit]. shipmwavemax : numpy.ndarray Maximum bank level subject to ship waves [m] shipwavemin : numpy.ndarray Minimum bank level subject to ship waves [m] waterlevelq_txt : str Label for the water level per discharge level. avg_waterlevel_txt : str Label for the average water level. shipwave_txt : str Label for the elevation range influenced by ship waves. bankheight : List[numpy.ndarray] List of arrays containing the bank heights per bank (segment) [elevation_unit]. bankheight_txt : str Label for the bank height. bankprotect : List[numpy.ndarray] List of arrays containing the bank protection height per bank (point) [elevation_unit]. bankprotect_txt : str Label for the bank protection height. elevation_txt : str General label for elevation data. title_txt : str Label for the axes title. elevation_unit : str Unit used for all elevation data.
Results#
figlist : List[matplotlib.figure.Figure] List of figure objects, one per bank. axlist : List[matplotlib.axes.Axes] List of axes objects, one per bank.
Source code in src/dfastbe/plotting.py
865 866 867 868 869 870 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 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 |
|
plot6series_velocity_per_bank(bank_km_mid: List[numpy.ndarray], chainage_txt: str, veloc: List[List[numpy.ndarray]], velocq_txt: str, tauc: List[numpy.ndarray], chezy: List[numpy.ndarray], ucrit_txt: str, ylabel_txt: str, title_txt: str, veloc_unit: str) -> [List[matplotlib.figure.Figure], List[matplotlib.axes.Axes]]
#
Create the bank erosion plots with velocities and critical velocities along each bank.
Arguments#
bank_km_mid : List[numpy.ndarray] List of arrays containing the chainage values per bank (segment) [km]. chainage_txt : str Label for the horizontal chainage axes. veloc: List[List[numpy.ndarray]] List of arrays containing the velocities per bank (segment) [m/s]. velocq_txt: str, Label for the velocity per discharge level. tauc: List[numpy.ndarray] List of arrays containing the shear stresses per bank (point) [N/m2]. chezy: List[numpy.ndarray] List of arrays containing the Chezy values per bank [m0.5/s]. ucrit_txt: str Label for the critical velocity. ylabel_txt: str Label for the vertical (velocity) axis. title_txt: str Label for the axes title. veloc_unit: str Unit used for all velocities.
Results#
figlist : List[matplotlib.figure.Figure] List of figure objects, one per bank. axlist : List[matplotlib.axes.Axes] List of axes objects, one per bank.
Source code in src/dfastbe/plotting.py
1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 |
|
plot7_banktype(bbox: Tuple[float, float, float, float], xykm: numpy.ndarray, bank_crds: List[numpy.ndarray], banktype: List[numpy.ndarray], taucls_str: List[str], xlabel_txt: str, ylabel_txt: str, title_txt: str) -> [matplotlib.figure.Figure, matplotlib.axes.Axes]
#
Create the bank erosion plot with colour-coded bank types.
Arguments#
bbox : Tuple[float, float, float, float] Tuple containing boundary limits (xmin, ymin, xmax, ymax); unit m. xykm : numpy.ndarray Array containing the x, y, and chainage; unit m for x and y, km for chainage. bank_crds : List[numpy.ndarray] List of N arrays containing the x- and y-coordinates of the oroginal bank lines. banktype : List[numpy.ndarray] List of N arrays containing the bank type values. taucls_str : List[str] List of strings representing the distinct bank type classes. xlabel_txt : str Label for the x-axis. ylabel_txt : str Label for the y-axis. title_txt : str Label for the axes title.
Results#
fig : matplotlib.figure.Figure Figure object. ax : matplotlib.axes.Axes Axes object.
Source code in src/dfastbe/plotting.py
1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 |
|
plot8_eroded_distance(bank_km_mid: List[numpy.ndarray], chainage_txt: str, dn_tot: List[numpy.ndarray], dn_tot_txt: str, dn_eq: List[numpy.ndarray], dn_eq_txt: str, dn_txt: str, dn_unit: str) -> [matplotlib.figure.Figure, matplotlib.axes.Axes]
#
Create the bank erosion plot with total and equilibrium eroded distance.
Arguments#
bank_km_mid : List[numpy.ndarray] List of arrays containing the chainage values per bank (segment) [km]. chainage_txt : str Label for the horizontal chainage axes. dn_tot : List[numpy.ndarray] List of arrays containing the total bank erosion distance per bank (segment) [m]. dn_tot_txt : str Label for the total bank erosion distance. dn_eq : List[numpy.ndarray] List of arrays containing the equilibrium bank erosion distance per bank (segment) [m]. dn_eq_txt : str Label for equilibrium bank erosion distance. dn_txt : str General label for bank erosion distance. dn_unit: str Unit used for bank erosion distance.
Results#
fig : matplotlib.figure.Figure Figure object. ax : matplotlib.axes.Axes Axes object.
Source code in src/dfastbe/plotting.py
1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 |
|
plot_detect1(bbox: Tuple[float, float, float, float], xykm: numpy.ndarray, bankareas: List[Polygon], bank: List[LineString], fn: numpy.ndarray, nnodes: numpy.ndarray, xn: numpy.ndarray, yn: numpy.ndarray, h: numpy.ndarray, hmax: float, xlabel_txt: str, ylabel_txt: str, title_txt: str, waterdepth_txt: str, bankarea_txt: str, bankline_txt: str, config_file: ConfigFile) -> [matplotlib.figure.Figure, matplotlib.axes.Axes]
#
Create the bank line detection plot.
The figure contains a map of the water depth, the chainage, and detected bank lines.
Arguments#
bbox : Tuple[float, float, float, float] Tuple containing boundary limits (xmin, ymin, xmax, ymax); unit m. xykm : numpy.ndarray Array containing the x, y, and chainage; unit m for x and y, km for chainage. bankareas : List[Polygon] List of bank polygons. bank : List[LineString] List of bank lines. fn : numpy.ndarray N x M array listing the nodes (max M) per face (total N) of the mesh. nnodes : numpy.ndarray Number of nodes per face (max M). xn : numpy.ndarray X-coordinates of the mesh nodes. yn : numpy.ndarray Y-coordinates of the mesh nodes. h : numpy.ndarray Array of water depth values. hmax : float Water depth value to be used as upper limit for coloring. xlabel_txt : str Label for the x-axis. ylabel_txt : str Label for the y-axis. title_txt : str Label for the axes title. waterdepth_txt : str Label for the color bar. bankarea_txt : str Label for the bank search areas. bankline_txt : str Label for the identified bank lines.
Returns#
fig : matplotlib.figure.Figure: Figure object. ax : matplotlib.axes.Axes Axes object.
Source code in src/dfastbe/plotting.py
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 |
|
plot_mesh(ax: matplotlib.axes.Axes, xe: numpy.ndarray, ye: numpy.ndarray, scale: float = 1000) -> None
#
Add a mesh to a plot.
Arguments#
ax : matplotlib.axes.Axes Axes object in which to add the mesh. xe : numpy.ndarray M x 2 array of begin/end x-coordinates of mesh edges. ye : numpy.ndarray M x 2 array of begin/end y-coordinates of mesh edges. scale : float Indicates whether the axes are in m (1) or km (1000).
Source code in src/dfastbe/plotting.py
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 |
|
plot_mesh_patches(ax: matplotlib.axes.Axes, fn: numpy.ndarray, nnodes: numpy.ndarray, xn: numpy.ndarray, yn: numpy.ndarray, val: numpy.ndarray, minval: Optional[float] = None, maxval: Optional[float] = None, scale: float = 1000) -> matplotlib.collections.PolyCollection
#
Add a collection of patches to the plot one for every face of the mesh.
Arguments#
ax : matplotlib.axes.Axes Axes object in which to add the mesh. fn : numpy.ndarray N x M array listing the nodes (max M) per face (total N) of the mesh. nnodes : numpy.ndarray Number of nodes per face (max M). xn : numpy.ndarray X-coordinates of the mesh nodes. yn : numpy.ndarray Y-coordinates of the mesh nodes. val : numpy.ndarray Array of length N containing the value per face. minval : Optional[float] Lower limit for the color scale. maxval : Optional[float] Upper limit for the color scale. scale : float Indicates whether the axes are in m (1) or km (1000).
Returns#
p : matplotlib.collections.PolyCollection Patches object.
Source code in src/dfastbe/plotting.py
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 |
|
savefig(fig: matplotlib.figure.Figure, filename: str) -> None
#
Save a single figure to file.
Arguments#
fig : matplotlib.figure.Figure Figure to a be saved. filename : str Name of the file to be written.
Source code in src/dfastbe/plotting.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
set_bbox(ax: matplotlib.axes.Axes, bbox: Tuple[float, float, float, float], scale: float = 1000) -> None
#
Specify the bounding limits of an axes object.
Arguments#
ax : matplotlib.axes.Axes Axes object to be adjusted. bbox : Tuple[float, float, float, float] Tuple containing boundary limits (xmin, ymin, xmax, ymax); unit m. scale: float Indicates whether the axes are in m (1) or km (1000).
Source code in src/dfastbe/plotting.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
|
setsize(fig: matplotlib.figure.Figure) -> None
#
Set the size of a figure.
Currently the size is hardcoded, but functionality may be extended in the future.
Arguments#
fig : matplotlib.figure.Figure Figure to a be saved.
Source code in src/dfastbe/plotting.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
|
zoom_x_and_save(fig: matplotlib.figure.Figure, ax: matplotlib.axes.Axes, figbase: str, plot_ext: str, xzoom: List[Tuple[float, float]]) -> None
#
Zoom in on subregions of the x-axis and save the figure.
Arguments#
fig : matplotlib.figure.Figure Figure to be processed. ax : matplotlib.axes.Axes Axes to be processed. fig_base : str Base name of the figure to be saved. plot_ext : str File extension of the figure to be saved. xzoom : List[list[float,float]] Values at which to split the x-axis.
Source code in src/dfastbe/plotting.py
1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 |
|
zoom_xy_and_save(fig: matplotlib.figure.Figure, ax: matplotlib.axes.Axes, figbase: str, plot_ext: str, xyzoom: List[Tuple[float, float, float, float]], scale: float = 1000) -> None
#
Zoom in on subregions in x,y-space and save the figure.
Arguments#
fig : matplotlib.figure.Figure Figure to be processed. ax : matplotlib.axes.Axes Axes to be processed. fig_base : str Base name of the figure to be saved. plot_ext : str File extension of the figure to be saved. xyzoom : List[List[float, float, float, float]] List of xmin, xmax, ymin, ymax values to zoom into. scale: float Indicates whether the axes are in m (1) or km (1000).
Source code in src/dfastbe/plotting.py
1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 |
|
The plotting functions component provides functions for creating various types of visualizations, such as:
- Maps of bank lines and erosion results
- Profiles of bank erosion
- Time series of erosion volumes
- Visualizations of hydrodynamic data
Workflow#
The typical workflow for using the Plotting module is:
- Perform bank line detection or erosion calculation
- Call the appropriate plotting functions to visualize the results
- Display the plots or save them to files
Usage Example#
import matplotlib.pyplot as plt
from dfastbe import plotting as df_plt
from dfastbe.io.config import ConfigFile
from dfastbe.bank_erosion.bank_erosion import Erosion
# Load configuration file
config_file = ConfigFile.read("config.cfg")
# Initialize Erosion object
erosion = Erosion(config_file)
# Run erosion calculation
erosion.run()
# Create a plot of the results
fig, ax = plt.subplots(figsize=(10, 8))
df_plt.plot_bank_lines(ax, bank_lines, color='blue', linewidth=1.5)
df_plt.plot_erosion_results(ax, erosion_results, cmap='viridis')
plt.savefig("erosion_results.png")
plt.show()
For more details on the specific functions, refer to the API reference below.