Skip to content

Commit

Permalink
fix ylabel in distribution plots
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhundhausen committed Oct 21, 2024
1 parent e9643ef commit 771dbbd
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions menu_tools/object_performance/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,13 @@ def _outdir_distributions(self) -> str:
"outputs", self.version, "object_performance", "distributions"
)

def _style_plot(self, fig, ax, legend_loc="lower right"):
def _style_plot(self, fig, ax, legend_loc="lower right", ylabel=False):
ax.axvline(self.threshold, ls=":", c="k")
ax.axhline(1, ls=":", c="k")
ax.legend(loc=legend_loc, frameon=False)
ax.set_xlabel(rf"{self.cfg.xlabel}")
ylabel = self.cfg.ylabel.replace("<threshold>", str(self.threshold))
if not ylabel:
ylabel = self.cfg.ylabel.replace("<threshold>", str(self.threshold))
ax.set_ylabel(rf"{ylabel}")
ax.set_xlim(self.cfg.bin_min, self.cfg.bin_max)
ax.tick_params(direction="in")
Expand Down Expand Up @@ -291,7 +292,9 @@ def _plot_raw_counts(self):
**err_kwargs,
)

self._style_plot(fig, ax, legend_loc="best")
ylabel = self.cfg.ylabel.replace("<threshold>", str(self.threshold))
ylabel = ylabel.replace("Trigger Efficiency", "Events")
self._style_plot(fig, ax, legend_loc="best", ylabel=ylabel)
# Save figure
plot_fname = f"{self.plot_name}_{self.threshold}_dist_{self.version}"
plt.savefig(os.path.join(self._outdir_distributions, f"{plot_fname}.png"))
Expand Down

0 comments on commit 771dbbd

Please sign in to comment.