diff --git a/mlair/plotting/postprocessing_plotting.py b/mlair/plotting/postprocessing_plotting.py index 8ecf5ec7f9aef53bb42f312fd68bb0b7a305288d..66679a22bcf0d6a2da4702bf6d41e0fb61b6f62a 100644 --- a/mlair/plotting/postprocessing_plotting.py +++ b/mlair/plotting/postprocessing_plotting.py @@ -854,6 +854,7 @@ class PlotFeatureImportanceSkillScore(AbstractPlotClass): # pragma: no cover except NotImplementedError: pass _, sampling_letter = self._get_sampling(sampling, 1) + 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) @@ -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"{self._sampling}{ahead}" + 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 = [self.sampling + str(i) 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 = [self.sampling + str(i) 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 = [self.sampling + str(i) 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) @@ -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} ({self.sampling}{ahead})" + 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()