Skip to content

Commit

Permalink
feat: allow setting c-o-m in exp label (#433)
Browse files Browse the repository at this point in the history
* Update label.py

Remove hard-coded lumi for loc==4

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update label.py

Correctly format com and lumi

* fix: fix tests

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Andrzej Novak <[email protected]>
  • Loading branch information
3 people authored Feb 3, 2025
1 parent ec5e150 commit 2584d47
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/mplhep/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,11 +403,19 @@ def exp_label(
_com_label = r"\mathrm{13\ TeV}"

if lumi is not None:
_lumi = (
r"$\sqrt{s} = " + _com_label + ", " + str(lumi) + r"\ \mathrm{fb}^{-1}$"
_lumi = r"{com}, {lumi}".format(
com=r"$\sqrt{s} = \mathrm{" + str(com) + r"\ TeV}$"
if com is not None
else r"$\sqrt{s} = \mathrm{13\ TeV}$",
lumi=lumi_format.format(lumi) + r" $\mathrm{fb^{-1}}$",
)
else:
_lumi = r"$\sqrt{s} = " + _com_label + "$"
_lumi = r"{com}".format(
com=r"$\sqrt{s} = \mathrm{" + str(com) + r"\ TeV}$"
if com is not None
else r"$\sqrt{s} = \mathrm{13\ TeV}$",
)

explumi = ExpSuffix(
*exptext.get_position(),
text=rlabel if rlabel is not None else _lumi,
Expand Down
Binary file modified tests/baseline/test_label_loc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/baseline/test_pub_loc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2584d47

Please sign in to comment.