@@ -828,9 +828,7 @@ def plot_gridded_dataset(
828828 gridded : numpy .ndarray ,
829829 region : "CartesianGrid2D" ,
830830 basemap : Optional [str ] = None ,
831- ax : Optional [pyplot .Axes ] = None ,
832831 projection : Optional [Union [ccrs .Projection , str ]] = None ,
833- show : bool = False ,
834832 extent : Optional [List [float ]] = None ,
835833 set_global : bool = False ,
836834 plot_region : bool = True ,
@@ -840,6 +838,8 @@ def plot_gridded_dataset(
840838 clabel : Optional [str ] = None ,
841839 alpha : Optional [float ] = None ,
842840 alpha_exp : float = 0 ,
841+ ax : Optional [pyplot .Axes ] = None ,
842+ show : bool = False ,
843843 ** kwargs ,
844844) -> matplotlib .axes .Axes :
845845 """
@@ -856,11 +856,9 @@ def plot_gridded_dataset(
856856 (whose indices correspond to each spatial cell) to a 2D-square array.
857857 region (CartesianGrid2D): Region in which gridded values are contained.
858858 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`.
860859 projection (cartopy.crs.Projection or str): Projection to be used in the underlying
861860 basemap. It can be a cartopy projection instance, or `approx` for a quick
862861 approximation of Mercator. Defaults to :class:`~cartopy.crs.PlateCarree` if `None`.
863- show (bool): If `True`, displays the plot. Defaults to `False`.
864862 extent (list of float): ``[lon_min, lon_max, lat_min, lat_max]``. Defaults to `None`.
865863 set_global (bool): Display the complete globe as basemap. Defaults to `False`.
866864 plot_region (bool): If `True`, plot the dataset region border. Defaults to `True`.
@@ -871,6 +869,8 @@ def plot_gridded_dataset(
871869 alpha (float): Transparency level. Defaults to `None`.
872870 alpha_exp (float): Exponent for the alpha function (recommended between `0.4` and `1`).
873871 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`.
874874 **kwargs: Additional keyword arguments to customize the plot:
875875
876876 - **colorbar_labelsize** (`int`): Font size for the colorbar label.
@@ -953,11 +953,11 @@ def plot_test_distribution(
953953 evaluation_result : "EvaluationResult" ,
954954 bins : Union [str , int , List [Any ]] = "fd" ,
955955 percentile : Optional [int ] = 95 ,
956- ax : Optional [matplotlib .axes .Axes ] = None ,
957956 auto_annotate : Union [bool , dict ] = True ,
958957 sim_label : str = "Simulated" ,
959958 obs_label : str = "Observation" ,
960959 legend : bool = True ,
960+ ax : Optional [matplotlib .axes .Axes ] = None ,
961961 show : bool = False ,
962962 ** kwargs ,
963963) -> matplotlib .axes .Axes :
@@ -1096,8 +1096,8 @@ def plot_test_distribution(
10961096def plot_calibration_test (
10971097 evaluation_result : "EvaluationResult" ,
10981098 percentile : float = 95 ,
1099- ax : Optional [matplotlib .axes .Axes ] = None ,
11001099 label : Optional [str ] = None ,
1100+ ax : Optional [matplotlib .axes .Axes ] = None ,
11011101 show : bool = False ,
11021102 ** kwargs ,
11031103) -> matplotlib .axes .Axes :
@@ -1261,6 +1261,13 @@ def _plot_comparison_test(
12611261 plot_args = {** DEFAULT_PLOT_ARGS , ** kwargs .get ("plot_args" , {}), ** kwargs }
12621262 fig , ax = pyplot .subplots (figsize = plot_args ["figsize" ]) if ax is None else (ax .figure , ax )
12631263
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+
12641271 # Iterate through T-test results, or jointly through t- and w- test results
12651272 Results = zip (results_t , results_w ) if results_w else zip (results_t )
12661273 for index , result in enumerate (Results ):
@@ -1337,11 +1344,15 @@ def _plot_comparison_test(
13371344
13381345 if plot_args ["legend" ]:
13391346 # Add custom legend to explain results
1347+
13401348 legend_elements = [
13411349 Line2D ([0 ], [0 ], color = "red" , lw = 2 ,
13421350 label = f"T-test rejected ($\\ alpha = { results_t [0 ].quantile [- 1 ]} $)" ),
13431351 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 ([
13451356 Line2D (
13461357 [0 ],
13471358 [0 ],
@@ -1361,8 +1372,8 @@ def _plot_comparison_test(
13611372 markersize = 6 ,
13621373 markerfacecolor = "white" ,
13631374 label = "W-test indistinguishable" ,
1364- ),
1365- ]
1375+ )])
1376+
13661377 ax .legend (handles = legend_elements , loc = "best" , fontsize = plot_args ["legend_fontsize" ])
13671378
13681379 if plot_args ["tight_layout" ]:
@@ -1379,9 +1390,9 @@ def _plot_consistency_test(
13791390 normalize : bool = False ,
13801391 one_sided_lower : bool = False ,
13811392 percentile : float = 95 ,
1382- ax : Optional [pyplot .Axes ] = None ,
13831393 plot_mean : bool = False ,
13841394 color : str = "black" ,
1395+ ax : Optional [pyplot .Axes ] = None ,
13851396 show : bool = False ,
13861397 ** kwargs ,
13871398) -> matplotlib .axes .Axes :
@@ -1523,8 +1534,8 @@ def _plot_concentration_ROC_diagram(
15231534 catalog : "CSEPCatalog" ,
15241535 linear : bool = True ,
15251536 plot_uniform : bool = True ,
1526- show : bool = True ,
15271537 ax : Optional [pyplot .Axes ] = None ,
1538+ show : bool = True ,
15281539 ** kwargs ,
15291540) -> matplotlib .axes .Axes :
15301541 """
@@ -1649,8 +1660,8 @@ def _plot_ROC_diagram(
16491660 catalog : "CSEPCatalog" ,
16501661 linear : bool = True ,
16511662 plot_uniform : bool = True ,
1652- show : bool = True ,
16531663 ax : Optional [pyplot .Axes ] = None ,
1664+ show : bool = True ,
16541665 ** kwargs ,
16551666) -> matplotlib .pyplot .Axes :
16561667 """
@@ -1786,8 +1797,8 @@ def _plot_Molchan_diagram(
17861797 catalog : "CSEPCatalog" ,
17871798 linear : bool = True ,
17881799 plot_uniform : bool = True ,
1789- show : bool = True ,
17901800 ax : Optional [pyplot .Axes ] = None ,
1801+ show : bool = True ,
17911802 ** kwargs ,
17921803) -> matplotlib .axes .Axes :
17931804
0 commit comments