diff --git a/mlair/plotting/postprocessing_plotting.py b/mlair/plotting/postprocessing_plotting.py index 7080a6b6472716c60996e462887d0feaf1a6a9ba..33150fae46da2f588d8a212d5d4297fcf5478cfa 100644 --- a/mlair/plotting/postprocessing_plotting.py +++ b/mlair/plotting/postprocessing_plotting.py @@ -31,7 +31,7 @@ logging.getLogger('matplotlib').setLevel(logging.WARNING) @TimeTrackingWrapper -class PlotMonthlySummary(AbstractPlotClass): +class PlotMonthlySummary(AbstractPlotClass): # pragma: no cover """ Show a monthly summary over all stations for each lead time ("ahead") as box and whiskers plot. @@ -138,7 +138,7 @@ class PlotMonthlySummary(AbstractPlotClass): @TimeTrackingWrapper -class PlotConditionalQuantiles(AbstractPlotClass): +class PlotConditionalQuantiles(AbstractPlotClass): # pragma: no cover """ Create cond.quantile plots as originally proposed by Murphy, Brown and Chen (1989) [But in log scale]. @@ -382,7 +382,7 @@ class PlotConditionalQuantiles(AbstractPlotClass): @TimeTrackingWrapper -class PlotClimatologicalSkillScore(AbstractPlotClass): +class PlotClimatologicalSkillScore(AbstractPlotClass): # pragma: no cover """ Create plot of climatological skill score after Murphy (1988) as box plot over all stations. @@ -474,7 +474,7 @@ class PlotClimatologicalSkillScore(AbstractPlotClass): @TimeTrackingWrapper -class PlotCompetitiveSkillScore(AbstractPlotClass): +class PlotCompetitiveSkillScore(AbstractPlotClass): # pragma: no cover """ Create competitive skill score plot. @@ -591,7 +591,7 @@ class PlotCompetitiveSkillScore(AbstractPlotClass): @TimeTrackingWrapper -class PlotBootstrapSkillScore(AbstractPlotClass): +class PlotBootstrapSkillScore(AbstractPlotClass): # pragma: no cover """ Create plot of climatological skill score after Murphy (1988) as box plot over all stations. @@ -840,7 +840,7 @@ class PlotBootstrapSkillScore(AbstractPlotClass): @TimeTrackingWrapper -class PlotTimeSeries: +class PlotTimeSeries: # pragma: no cover """ Create time series plot. @@ -973,7 +973,7 @@ class PlotTimeSeries: @TimeTrackingWrapper -class PlotSeparationOfScales(AbstractPlotClass): +class PlotSeparationOfScales(AbstractPlotClass): # pragma: no cover def __init__(self, collection: DataCollection, plot_folder: str = ".", time_dim="datetime", window_dim="window", filter_dim="filter", target_dim="variables"): @@ -999,7 +999,8 @@ class PlotSeparationOfScales(AbstractPlotClass): self._save() -class PlotSampleUncertaintyFromBootstrap(AbstractPlotClass): +@TimeTrackingWrapper +class PlotSampleUncertaintyFromBootstrap(AbstractPlotClass): # pragma: no cover def __init__(self, data: xr.DataArray, plot_folder: str = ".", model_type_dim: str = "type", error_measure: str = "mse", error_unit: str = None, dim_name_boots: str = 'boots'): @@ -1028,6 +1029,8 @@ class PlotSampleUncertaintyFromBootstrap(AbstractPlotClass): def prepare_data(self, data: xr.DataArray): self._data_table = data.to_pandas() + if "persi" in self._data_table.columns: + self._data_table["persi"] = self._data_table.pop("persi") self._n_boots = self._data_table.shape[0] def _apply_root(self): @@ -1038,19 +1041,19 @@ class PlotSampleUncertaintyFromBootstrap(AbstractPlotClass): def _plot(self, orientation: str = "v"): data_table = self._data_table n_boots = self._n_boots - size = max([len(np.unique(data_table.columns)), 6]) + size = len(np.unique(data_table.columns)) if orientation == "v": - figsize = (size, size * 0.8) + figsize, width = (size, 5), 0.4 elif orientation == "h": - figsize = (size * 0.8, size) + figsize, width = (6, (1+.5*size)), 0.65 else: raise ValueError(f"orientation must be `v' or `h' but is: {orientation}") fig, ax = plt.subplots(figsize=figsize) sns.boxplot(data=data_table, ax=ax, whis=1., color="white", - showmeans=True, meanprops={"markersize": 3, "markeredgecolor": "k"}, - flierprops={"marker": "o", "markerfacecolor": "black", "markeredgecolor": "none","markersize": 3}, + showmeans=True, meanprops={"markersize": 6, "markeredgecolor": "k"}, + flierprops={"marker": "o", "markerfacecolor": "black", "markeredgecolor": "none", "markersize": 3}, boxprops={'facecolor': 'none', 'edgecolor': 'k'}, - width=.3, orient=orientation) + width=width, orient=orientation) if orientation == "v": ax.set_ylabel(f"{self.error_measure} (in {self.error_unit})") ax.set_xticklabels(ax.get_xticklabels(), rotation=45) @@ -1058,7 +1061,7 @@ class PlotSampleUncertaintyFromBootstrap(AbstractPlotClass): ax.set_xlabel(f"{self.error_measure} (in {self.error_unit})") else: raise ValueError(f"orientation must be `v' or `h' but is: {orientation}") - text_box = AnchoredText(f"n={n_boots}", frameon=True, loc=4, pad=0.5) + text_box = AnchoredText(f"n={n_boots}", frameon=True, loc=1, pad=0.5) plt.setp(text_box.patch, edgecolor='k', facecolor='w') ax.add_artist(text_box) plt.setp(ax.lines, color='k')