diff --git a/mlair/plotting/postprocessing_plotting.py b/mlair/plotting/postprocessing_plotting.py index 7034c513328d6587e10925fe5782a17d3bd033e8..68f82a7746305d99913271ca9134ce4f310ee6d3 100644 --- a/mlair/plotting/postprocessing_plotting.py +++ b/mlair/plotting/postprocessing_plotting.py @@ -1333,11 +1333,14 @@ class PlotRankHistogram(AbstractPlotClass): pdf_pages = matplotlib.backends.backend_pdf.PdfPages(plot_path) for ah in value[self.ahead_dim]: fig, ax = plt.subplots() - ax.bar(value.sel({"rank_hist_type": "bins", self.ahead_dim: ah.values}), - value.sel({"rank_hist_type": "freq", self.ahead_dim: ah.values}), - align='center') - ax.set_xlabel(f"{self.target_var} (in {self.target_unit})") - ax.set_ylabel("freq") + bins = value.sel({"rank_hist_type": "bins", self.ahead_dim: ah.values}) + freq = value.sel({"rank_hist_type": "freq", self.ahead_dim: ah.values}) + relfreq = freq/freq.sum() + ax.bar(bins, relfreq, align='center', color="gray") + ax.hlines(1. / len(bins), 0, len(bins), color="black", linestyle="dashed") + ax.set_xlabel(r"Verification Rank ($n_{ens}+1$)") + ax.set_ylabel("Relative Frequency") + plt.title(f"{ah.values}") pdf_pages.savefig() plt.close('all')