diff --git a/mlair/plotting/postprocessing_plotting.py b/mlair/plotting/postprocessing_plotting.py index 8d7bfd0c37966b623f99ac72f316e36aa241dd3b..e52c60f06f152908aec504f6725f67b9d3e6f1a0 100644 --- a/mlair/plotting/postprocessing_plotting.py +++ b/mlair/plotting/postprocessing_plotting.py @@ -833,7 +833,7 @@ class PlotBootstrapSkillScore(AbstractPlotClass): self._data = self._prepare_data(data) self._individual_vars = set(self._data[self._x_name].values) self._plot() - self._save() + self._save(bbox_inches='tight') self.plot_name += '_separated' self._plot(separate_vars=separate_vars) self._save(bbox_inches='tight') @@ -903,6 +903,10 @@ class PlotBootstrapSkillScore(AbstractPlotClass): order_first = self.set_order_for_x_axis(separate_vars) order_second = self.set_order_for_x_axis(remaining_vars) + order_second, center_names_second = self.set_order_for_x_axis(remaining_vars, return_center_names=True) + number_of_vars_second = len(order_second) + group_size = int(number_of_vars_second / len(center_names_second)) + fig, ax = plt.subplots(nrows=1, ncols=2, figsize=(len(self._individual_vars) / 2, 10), gridspec_kw={'width_ratios': [len(separate_vars), @@ -926,6 +930,8 @@ class PlotBootstrapSkillScore(AbstractPlotClass): flierprops={"marker": "."}, ) ax[1].set(ylabel="", xlabel="") + if group_size > 1: + [ax[1].axvline(x + .5, color='grey') for i, x in enumerate(ax[1].get_xticks(), start=1) if i % group_size == 0] ax[1].yaxis.tick_right() handles, _ = ax[1].get_legend_handles_labels() for sax in ax: @@ -987,8 +993,8 @@ class PlotBootstrapSkillScore(AbstractPlotClass): """ number_of_vars = len(self._individual_vars) - order = self.set_order_for_x_axis(self._individual_vars) - + order, center_names = self.set_order_for_x_axis(self._individual_vars, return_center_names=True) + group_size = int(number_of_vars / len(center_names)) if number_of_vars > 20: fig, ax = plt.subplots(figsize=(number_of_vars/2, 10)) @@ -998,6 +1004,8 @@ class PlotBootstrapSkillScore(AbstractPlotClass): showmeans=True, meanprops={"markersize": 1, "markeredgecolor": "k"}, flierprops={"marker": "."}, order=order) ax.axhline(y=0, color="grey", linewidth=.5) + if group_size > 1: + [ax.axvline(x + .5, color='grey') for i, x in enumerate(ax.get_xticks(), start=1) if i % group_size == 0] plt.xticks(rotation=45, horizontalalignment="right") ax.set(ylabel=f"skill score", xlabel="", title="summary of all stations") handles, _ = ax.get_legend_handles_labels() @@ -1005,7 +1013,7 @@ class PlotBootstrapSkillScore(AbstractPlotClass): plt.tight_layout() @staticmethod - def set_order_for_x_axis(var_list, sect_split_name="Sect"): + def set_order_for_x_axis(var_list, sect_split_name="Sect", return_center_names=False): try: split_names = [i.split(sect_split_name) for i in var_list] center_name = [] @@ -1022,8 +1030,10 @@ class PlotBootstrapSkillScore(AbstractPlotClass): new_order += [center] + [center+sect_split_name+sec for sec in sector_identifier] except: new_order = None - - return new_order + if return_center_names: + return new_order, center_name + else: + return new_order