diff --git a/mlair/plotting/postprocessing_plotting.py b/mlair/plotting/postprocessing_plotting.py index 69c8d00b6cafb1d8471f1e2a45c946145dfeff59..ac6ef0b8155271286a47f49f5adb5bc5bbaac610 100644 --- a/mlair/plotting/postprocessing_plotting.py +++ b/mlair/plotting/postprocessing_plotting.py @@ -676,8 +676,11 @@ class PlotSectorialSkillScore(AbstractPlotClass): # pragma: no cover :return: """ limit = 5 - lower = np.max([-limit, np.min([0, helpers.float_round(data["data"].min(), 2) - 0.1])]) - upper = np.min([limit, helpers.float_round(data["data"].max(), 2) + 0.1]) + try: + lower = np.max([-limit, np.min([0, helpers.float_round(data["data"].min(), 2) - 0.1])]) + upper = np.min([limit, helpers.float_round(data["data"].max(), 2) + 0.1]) + except ValueError: + lower, upper = (-limit, limit) return lower, upper @@ -765,7 +768,7 @@ class PlotFeatureImportanceSkillScore(AbstractPlotClass): # pragma: no cover def _set_title(self, model_name, branch=None, n_branches=None): title_d = {"single input": "Single Inputs", "branch": "Input Branches", "variable": "Variables", - "group_of_variables_sector": "grouped variables by sector", + "group_of_variables_sector": "grouped variables by sector", "group_of_variables_var_in_sectors": "grouped variables across sectors"} base_title = f"{model_name}\nImportance of {title_d[self._boot_type]}" @@ -1083,15 +1086,17 @@ class PlotFeatureImportanceSkillScore(AbstractPlotClass): # pragma: no cover #>>>>>>> c1f8954cc667698400527de794aaf928bcfbdefb plot_data = self._data if branch is None else self._data[self._data["branch"] == str(branch)] + alphabetical_order = sorted(plot_data[self._x_name].unique().tolist(), key=str.casefold) if self._boot_type == "branch": fig, ax = plt.subplots(figsize=(0.5 + 2 / len(plot_data[self._x_name].unique()) + len(plot_data[self._x_name].unique()),4)) sns.boxplot(x=self._x_name, y="data", hue=self._ahead_dim, data=plot_data, ax=ax, whis=1., palette="Blues_r", showmeans=True, meanprops={"markersize": 1, "markeredgecolor": "k"}, - showfliers=False, width=0.8) + showfliers=False, width=0.8, order=alphabetical_order) else: fig, ax = plt.subplots() sns.boxplot(x=self._x_name, y="data", hue=self._ahead_dim, data=plot_data, ax=ax, whis=1.5, palette="Blues_r", - showmeans=True, meanprops={"markersize": 1, "markeredgecolor": "k"}, showfliers=False) + showmeans=True, meanprops={"markersize": 1, "markeredgecolor": "k"}, showfliers=False, + order=alphabetical_order) ax.axhline(y=0, color="grey", linewidth=.5) #<<<<<<< HEAD #=======