Skip to content
Snippets Groups Projects
Commit 469786fa authored by lukas leufen's avatar lukas leufen
Browse files

Merge branch 'lukas_issue301_refac_limit-axis-in-competing-skill-score-plot' into 'develop'

Resolve "refac: limit axis in competing skill score plot"

See merge request !286
parents 5c72060a 9cd6a8ab
No related branches found
No related tags found
5 merge requests!319add all changes of dev into release v1.4.0 branch,!318Resolve "release v1.4.0",!299Draft: Merge default data handler and preprocessing support parameter use_multiprocessing....,!286Resolve "refac: limit axis in competing skill score plot",!259Draft: Resolve "WRF-Datahandler should inherit from SingleStationDatahandler"
Pipeline #65525 passed
......@@ -659,7 +659,7 @@ class PlotClimatologicalSkillScore(AbstractPlotClass):
"""
return "" if score_only else "terms and "
def _plot(self, score_only):
def _plot(self, score_only, xlim=5):
"""
Plot climatological skill score.
......@@ -671,11 +671,26 @@ class PlotClimatologicalSkillScore(AbstractPlotClass):
sns.boxplot(x="terms", y="data", hue="ahead", data=self._data, ax=ax, whis=1., palette="Blues_d",
showmeans=True, meanprops={"markersize": 1, "markeredgecolor": "k"}, flierprops={"marker": "."})
ax.axhline(y=0, color="grey", linewidth=.5)
ax.set(ylabel=f"{self._label_add(score_only)}skill score", xlabel="", title="summary of all stations")
ax.set(ylabel=f"{self._label_add(score_only)}skill score", xlabel="", title="summary of all stations",
ylim=self._lim())
handles, _ = ax.get_legend_handles_labels()
ax.legend(handles, self._labels)
plt.tight_layout()
def _lim(self) -> Tuple[float, float]:
"""
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).
:return:
"""
limit = 5
lower = np.max([-limit, np.min([0, helpers.float_round(self._data["data"].min() - 0.1, 2)])])
upper = np.min([limit, helpers.float_round(self._data["data"].max() + 0.1, 2)])
return lower, upper
@TimeTrackingWrapper
class PlotCompetitiveSkillScore(AbstractPlotClass):
......@@ -747,8 +762,7 @@ class PlotCompetitiveSkillScore(AbstractPlotClass):
showmeans=True, meanprops={"markersize": 3, "markeredgecolor": "k"}, flierprops={"marker": "."},
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._lim())
ax.set(ylabel="skill score", xlabel="competing models", title="summary of all stations", ylim=self._lim(data))
handles, _ = ax.get_legend_handles_labels()
plt.xticks(rotation=90)
ax.legend(handles, self._labels)
......@@ -762,9 +776,8 @@ class PlotCompetitiveSkillScore(AbstractPlotClass):
sns.boxplot(y="comparison", x="data", hue="ahead", data=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())
ax.set(xlabel="skill score", ylabel="competing models", title="summary of all stations", xlim=self._lim(data))
handles, _ = ax.get_legend_handles_labels()
ax.legend(handles, self._labels)
plt.tight_layout()
......@@ -780,7 +793,8 @@ class PlotCompetitiveSkillScore(AbstractPlotClass):
filtered_headers = list(filter(lambda x: "nn-" in x, data.comparison.unique()))
return data[data.comparison.isin(filtered_headers)]
def _lim(self) -> Tuple[float, float]:
@staticmethod
def _lim(data) -> Tuple[float, float]:
"""
Calculate axis limits from data (Can be used to set axis extend).
......@@ -789,8 +803,9 @@ class PlotCompetitiveSkillScore(AbstractPlotClass):
:return:
"""
lower = np.min([0, helpers.float_round(self._data.min()[2], 2) - 0.1])
upper = helpers.float_round(self._data.max()[2], 2) + 0.1
limit = 5
lower = np.max([-limit, np.min([0, helpers.float_round(data.min()[2], 2) - 0.1])])
upper = np.min([limit, helpers.float_round(data.max()[2], 2) + 0.1])
return lower, upper
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment