diff --git a/mlair/plotting/postprocessing_plotting.py b/mlair/plotting/postprocessing_plotting.py index 6373d3b61a4aa7ffb4ce782365b9ba1234761f0e..66679a22bcf0d6a2da4702bf6d41e0fb61b6f62a 100644 --- a/mlair/plotting/postprocessing_plotting.py +++ b/mlair/plotting/postprocessing_plotting.py @@ -854,7 +854,8 @@ class PlotFeatureImportanceSkillScore(AbstractPlotClass): # pragma: no cover except NotImplementedError: pass _, sampling_letter = self._get_sampling(sampling, 1) - self._labels = [str(i) + sampling_letter for i in data.coords[self._ahead_dim].values] + sampling_letter = {"d": "D", "h": "H"}.get(sampling_letter, sampling_letter) + self._labels = [sampling_letter + str(i) for i in data.coords[self._ahead_dim].values] if station_dim not in data.dims: data = data.expand_dims(station_dim) self._number_of_bootstraps = np.unique(data.coords[self._boot_dim].values).shape[0] @@ -1138,7 +1139,8 @@ class PlotTimeSeries: # pragma: no cover color = sns.color_palette("Blues_d", self._window_lead_time).as_hex() for ahead in data.coords[self._ahead_dim].values: plot_data = data.sel({"type": self._model_name, self._ahead_dim: ahead}).drop(["type", self._ahead_dim]).squeeze().shift(index=ahead) - label = f"{ahead}{self._sampling}" + sampling_letter = {"d": "D", "h": "H"}.get(self._sampling, self._sampling) + label = f"{sampling_letter}{ahead}" ax.plot(plot_data, color=color[ahead - 1], label=label) def _plot_obs(self, ax, data): @@ -1264,6 +1266,7 @@ class PlotSampleUncertaintyFromBootstrap(AbstractPlotClass): # pragma: no cover return # nothing to do n_boots = self._n_boots error_label = self.error_measure if self.error_unit is None else f"{self.error_measure} (in {self.error_unit})" + sampling_letter = {"d": "D", "h": "H"}.get(self.sampling, self.sampling) if agg_type == "single": fig, ax = plt.subplots() if self.ahead_dim in data_table.index.names: @@ -1291,7 +1294,7 @@ class PlotSampleUncertaintyFromBootstrap(AbstractPlotClass): # pragma: no cover g.map(sns.kdeplot, 0) g.add_legend(title="") fig = plt.gcf() - _labels = [str(i) + self.sampling for i in data_table.index.levels[1].values] + _labels = [sampling_letter + str(i) for i in data_table.index.levels[1].values] for axi, title in zip(g.axes.flatten(), _labels): axi.set_title(title) for axi in g.axes.flatten(): @@ -1324,6 +1327,7 @@ class PlotSampleUncertaintyFromBootstrap(AbstractPlotClass): # pragma: no cover size = len(np.unique(data_table.columns)) asteriks = self.get_asteriks_from_mann_whitney_u_result if apply_u_test is True else None color_palette = sns.color_palette("Blues_d", self._factor).as_hex() + sampling_letter = {"d": "D", "h": "H"}.get(self.sampling, self.sampling) if orientation == "v": figsize, width = (size, 5), 0.4 elif orientation == "h": @@ -1348,7 +1352,7 @@ class PlotSampleUncertaintyFromBootstrap(AbstractPlotClass): # pragma: no cover flierprops={"marker": "o", "markerfacecolor": "black", "markeredgecolor": "none", "markersize": 3}, boxprops={'edgecolor': 'k'}, width=.8, orient=orientation, **xy, hue=self.ahead_dim) - _labels = [str(i) + self.sampling for i in data_table.index.levels[1].values] + _labels = [sampling_letter + str(i) for i in data_table.index.levels[1].values] handles, _ = ax.get_legend_handles_labels() ax.legend(handles, _labels) else: @@ -1362,7 +1366,7 @@ class PlotSampleUncertaintyFromBootstrap(AbstractPlotClass): # pragma: no cover flierprops={"marker": "o", "markerfacecolor": "black", "markeredgecolor": "none", "markersize": 3}, boxprops={'facecolor': 'none', 'edgecolor': 'k'}, width=width, orient=orientation) - _labels = [str(i) + self.sampling for i in data_table.index.levels[1].values] + _labels = [sampling_letter + str(i) for i in data_table.index.levels[1].values] for axi, title in zip(ax.axes.flatten(), _labels): axi.set_title(title) plt.setp(axi.lines, color='k') @@ -1631,6 +1635,7 @@ class PlotSeasonalMSEStack(AbstractPlotClass): def _plot(self, dim, split_ahead=True, sampling="daily", orientation="vertical"): _, sampling_letter = self._get_sampling(sampling, 1) + sampling_letter = {"d": "D", "h": "H"}.get(sampling_letter, sampling_letter) if split_ahead is False: self.plot_name = self.plot_name_orig + "_total_" + orientation data = self._data.mean(dim) @@ -1658,7 +1663,7 @@ class PlotSeasonalMSEStack(AbstractPlotClass): fig, ax = plt.subplots(1, n, sharey=True, figsize=(np.prod(m) / 0.8, 5)) for i, sel in enumerate(data.coords[dim].values): data.sel({dim: sel}).to_pandas().T.plot.bar(ax=ax[i], stacked=True, cmap="Dark2", legend=False) - label = str(sel) + sampling_letter + label = sampling_letter + str(sel) ax[i].set_title(label) ax[i].xaxis.label.set_visible(False) self._set_bar_label(ax[i]) @@ -1669,7 +1674,7 @@ class PlotSeasonalMSEStack(AbstractPlotClass): fig, ax = plt.subplots(n, 1, sharex=True, figsize=(6, np.prod(m) * 0.6)) for i, sel in enumerate(data.coords[dim].values): data.sel({dim: sel}).to_pandas().T.plot.barh(ax=ax[i], stacked=True, cmap="Dark2", legend=False) - label = str(sel) + sampling_letter + label = sampling_letter + str(sel) ax[i].set_title(label) ax[i].yaxis.label.set_visible(False) self._set_bar_label(ax[i]) @@ -1763,7 +1768,8 @@ class PlotErrorsOnMap(AbstractPlotClass): cbar_label = f"{error_long_name} (in {error_units})" if error_units is not None else error_long_name plt.colorbar(cb, label=cbar_label) self._adjust_extent(ax) - title = model_type if ahead is None else f"{model_type} ({ahead}{self.sampling})" + sampling_letter = {"d": "D", "h": "H"}.get(self.sampling, self.sampling) + title = model_type if ahead is None else f"{model_type} ({sampling_letter}{ahead})" plt.title(title) plt.tight_layout()