diff --git a/mlair/plotting/postprocessing_plotting.py b/mlair/plotting/postprocessing_plotting.py index acfcca29cda2a43585e42742e2b202ba603f9339..59e98c5bd47f7fb1e24fc6f9f7a9dc05359b587e 100644 --- a/mlair/plotting/postprocessing_plotting.py +++ b/mlair/plotting/postprocessing_plotting.py @@ -702,6 +702,10 @@ class PlotCompetitiveSkillScore(AbstractPlotClass): self._data = self._prepare_data(data) self._plot() self._save() + # draw also a vertical version + self.plot_name += "_vertical" + self._plot_vertical() + self._save() def _prepare_data(self, data: pd.DataFrame) -> pd.DataFrame: """ @@ -720,7 +724,7 @@ class PlotCompetitiveSkillScore(AbstractPlotClass): return data.stack(level=0).reset_index(level=2, drop=True).reset_index(name="data") def _plot(self): - """Plot skill scores of the comparisons cnn-persi, ols-persi and cnn-ols.""" + """Plot skill scores of the comparisons.""" fig, ax = plt.subplots() order = self._create_pseudo_order() sns.boxplot(x="comparison", y="data", hue="ahead", data=self._data, whis=1., ax=ax, palette="Blues_d", @@ -728,7 +732,22 @@ class PlotCompetitiveSkillScore(AbstractPlotClass): order=order) ax.axhline(y=0, color="grey", linewidth=.5) - ax.set(ylabel="skill score", xlabel="competing models", title="summary of all stations", ylim=self._ylim()) + ax.set(ylabel="skill score", xlabel="competing models", title="summary of all stations", ylim=self._lim()) + handles, _ = ax.get_legend_handles_labels() + plt.xticks(rotation=20) + ax.legend(handles, self._labels) + plt.tight_layout() + + def _plot_vertical(self): + """Plot skill scores of the comparisons, but vertically aligned.""" + fig, ax = plt.subplots() + order = self._create_pseudo_order() + sns.boxplot(y="comparison", x="data", hue="ahead", data=self._data, whis=1., ax=ax, palette="Blues_d", + showmeans=True, meanprops={"markersize": 3, "markeredgecolor": "k"}, flierprops={"marker": "."}, + order=order) + # ax.axhline(x=0, color="grey", linewidth=.5) + ax.axvline(x=0, color="grey", linewidth=.5) + ax.set(xlabel="skill score", ylabel="competing models", title="summary of all stations", xlim=self._lim()) handles, _ = ax.get_legend_handles_labels() ax.legend(handles, self._labels) plt.tight_layout() @@ -739,9 +758,9 @@ class PlotCompetitiveSkillScore(AbstractPlotClass): uniq, index = np.unique(first_elements + self._data.comparison.unique().tolist(), return_index=True) return uniq[index.argsort()] - def _ylim(self) -> Tuple[float, float]: + def _lim(self) -> Tuple[float, float]: """ - Calculate y-axis limits from data. + Calculate axis limits from data (Can be used to set axis extend). Lower limit is the minimum of 0 and data's minimum (reduced by small subtrahend) and upper limit is data's maximum (increased by a small addend).