@@ -828,9 +828,7 @@ def plot_gridded_dataset(
828
828
gridded : numpy .ndarray ,
829
829
region : "CartesianGrid2D" ,
830
830
basemap : Optional [str ] = None ,
831
- ax : Optional [pyplot .Axes ] = None ,
832
831
projection : Optional [Union [ccrs .Projection , str ]] = None ,
833
- show : bool = False ,
834
832
extent : Optional [List [float ]] = None ,
835
833
set_global : bool = False ,
836
834
plot_region : bool = True ,
@@ -840,6 +838,8 @@ def plot_gridded_dataset(
840
838
clabel : Optional [str ] = None ,
841
839
alpha : Optional [float ] = None ,
842
840
alpha_exp : float = 0 ,
841
+ ax : Optional [pyplot .Axes ] = None ,
842
+ show : bool = False ,
843
843
** kwargs ,
844
844
) -> matplotlib .axes .Axes :
845
845
"""
@@ -856,11 +856,9 @@ def plot_gridded_dataset(
856
856
(whose indices correspond to each spatial cell) to a 2D-square array.
857
857
region (CartesianGrid2D): Region in which gridded values are contained.
858
858
basemap (str): Passed to :func:`~csep.utils.plots.plot_basemap` along with `kwargs`.
859
- ax (matplotlib.axes.Axes): Previously defined ax object. Defaults to `None`.
860
859
projection (cartopy.crs.Projection or str): Projection to be used in the underlying
861
860
basemap. It can be a cartopy projection instance, or `approx` for a quick
862
861
approximation of Mercator. Defaults to :class:`~cartopy.crs.PlateCarree` if `None`.
863
- show (bool): If `True`, displays the plot. Defaults to `False`.
864
862
extent (list of float): ``[lon_min, lon_max, lat_min, lat_max]``. Defaults to `None`.
865
863
set_global (bool): Display the complete globe as basemap. Defaults to `False`.
866
864
plot_region (bool): If `True`, plot the dataset region border. Defaults to `True`.
@@ -871,6 +869,8 @@ def plot_gridded_dataset(
871
869
alpha (float): Transparency level. Defaults to `None`.
872
870
alpha_exp (float): Exponent for the alpha function (recommended between `0.4` and `1`).
873
871
Defaults to `0`.
872
+ ax (matplotlib.axes.Axes): Previously defined ax object. Defaults to `None`.
873
+ show (bool): If `True`, displays the plot. Defaults to `False`.
874
874
**kwargs: Additional keyword arguments to customize the plot:
875
875
876
876
- **colorbar_labelsize** (`int`): Font size for the colorbar label.
@@ -953,11 +953,11 @@ def plot_test_distribution(
953
953
evaluation_result : "EvaluationResult" ,
954
954
bins : Union [str , int , List [Any ]] = "fd" ,
955
955
percentile : Optional [int ] = 95 ,
956
- ax : Optional [matplotlib .axes .Axes ] = None ,
957
956
auto_annotate : Union [bool , dict ] = True ,
958
957
sim_label : str = "Simulated" ,
959
958
obs_label : str = "Observation" ,
960
959
legend : bool = True ,
960
+ ax : Optional [matplotlib .axes .Axes ] = None ,
961
961
show : bool = False ,
962
962
** kwargs ,
963
963
) -> matplotlib .axes .Axes :
@@ -1096,8 +1096,8 @@ def plot_test_distribution(
1096
1096
def plot_calibration_test (
1097
1097
evaluation_result : "EvaluationResult" ,
1098
1098
percentile : float = 95 ,
1099
- ax : Optional [matplotlib .axes .Axes ] = None ,
1100
1099
label : Optional [str ] = None ,
1100
+ ax : Optional [matplotlib .axes .Axes ] = None ,
1101
1101
show : bool = False ,
1102
1102
** kwargs ,
1103
1103
) -> matplotlib .axes .Axes :
@@ -1261,6 +1261,13 @@ def _plot_comparison_test(
1261
1261
plot_args = {** DEFAULT_PLOT_ARGS , ** kwargs .get ("plot_args" , {}), ** kwargs }
1262
1262
fig , ax = pyplot .subplots (figsize = plot_args ["figsize" ]) if ax is None else (ax .figure , ax )
1263
1263
1264
+ # Handle case when there is only a single pair of t_results and w_results
1265
+ if not isinstance (results_t , list ):
1266
+ results_t = [results_t ]
1267
+
1268
+ if results_w is not None and not isinstance (results_w , list ):
1269
+ results_w = [results_w ]
1270
+
1264
1271
# Iterate through T-test results, or jointly through t- and w- test results
1265
1272
Results = zip (results_t , results_w ) if results_w else zip (results_t )
1266
1273
for index , result in enumerate (Results ):
@@ -1337,11 +1344,15 @@ def _plot_comparison_test(
1337
1344
1338
1345
if plot_args ["legend" ]:
1339
1346
# Add custom legend to explain results
1347
+
1340
1348
legend_elements = [
1341
1349
Line2D ([0 ], [0 ], color = "red" , lw = 2 ,
1342
1350
label = f"T-test rejected ($\\ alpha = { results_t [0 ].quantile [- 1 ]} $)" ),
1343
1351
Line2D ([0 ], [0 ], color = "green" , lw = 2 , label = "T-test non-rejected" ),
1344
- Line2D ([0 ], [0 ], color = "gray" , lw = 2 , label = "T-test indistinguishable" ),
1352
+ Line2D ([0 ], [0 ], color = "gray" , lw = 2 , label = "T-test indistinguishable" )
1353
+ ]
1354
+ if results_w is not None :
1355
+ legend_elements .extend ([
1345
1356
Line2D (
1346
1357
[0 ],
1347
1358
[0 ],
@@ -1361,8 +1372,8 @@ def _plot_comparison_test(
1361
1372
markersize = 6 ,
1362
1373
markerfacecolor = "white" ,
1363
1374
label = "W-test indistinguishable" ,
1364
- ),
1365
- ]
1375
+ )])
1376
+
1366
1377
ax .legend (handles = legend_elements , loc = "best" , fontsize = plot_args ["legend_fontsize" ])
1367
1378
1368
1379
if plot_args ["tight_layout" ]:
@@ -1379,9 +1390,9 @@ def _plot_consistency_test(
1379
1390
normalize : bool = False ,
1380
1391
one_sided_lower : bool = False ,
1381
1392
percentile : float = 95 ,
1382
- ax : Optional [pyplot .Axes ] = None ,
1383
1393
plot_mean : bool = False ,
1384
1394
color : str = "black" ,
1395
+ ax : Optional [pyplot .Axes ] = None ,
1385
1396
show : bool = False ,
1386
1397
** kwargs ,
1387
1398
) -> matplotlib .axes .Axes :
@@ -1523,8 +1534,8 @@ def _plot_concentration_ROC_diagram(
1523
1534
catalog : "CSEPCatalog" ,
1524
1535
linear : bool = True ,
1525
1536
plot_uniform : bool = True ,
1526
- show : bool = True ,
1527
1537
ax : Optional [pyplot .Axes ] = None ,
1538
+ show : bool = True ,
1528
1539
** kwargs ,
1529
1540
) -> matplotlib .axes .Axes :
1530
1541
"""
@@ -1649,8 +1660,8 @@ def _plot_ROC_diagram(
1649
1660
catalog : "CSEPCatalog" ,
1650
1661
linear : bool = True ,
1651
1662
plot_uniform : bool = True ,
1652
- show : bool = True ,
1653
1663
ax : Optional [pyplot .Axes ] = None ,
1664
+ show : bool = True ,
1654
1665
** kwargs ,
1655
1666
) -> matplotlib .pyplot .Axes :
1656
1667
"""
@@ -1786,8 +1797,8 @@ def _plot_Molchan_diagram(
1786
1797
catalog : "CSEPCatalog" ,
1787
1798
linear : bool = True ,
1788
1799
plot_uniform : bool = True ,
1789
- show : bool = True ,
1790
1800
ax : Optional [pyplot .Axes ] = None ,
1801
+ show : bool = True ,
1791
1802
** kwargs ,
1792
1803
) -> matplotlib .axes .Axes :
1793
1804
0 commit comments