Skip to content
Snippets Groups Projects
Commit 1c32a84f authored by leufen1's avatar leufen1
Browse files

PlotCompetitiveSkillScore has now a horizontal and vertical version

parent 9c56c82e
No related branches found
No related tags found
3 merge requests!253include current develop,!252Resolve "release v1.3.0",!196Resolve "Competitor Models"
Pipeline #57732 passed
......@@ -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).
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment