Hi,
i noticed, that in the plotting script plotdataMC.py the mplhep.mpl_magic function is used
|
try: |
|
hep.mpl_magic(ax=ax) |
|
except RuntimeError as e: |
|
print(f"Warning: {e}") |
|
print("Using soft_fail=True for legend placement") |
|
try: |
|
# Try with soft_fail=True |
|
hep.mpl_magic(ax=ax, soft_fail=True) |
|
except Exception as e2: |
|
print(f"Still failed: {e2}") |
|
# Continue anyway - the plot will still be usable |
however in mplhep there is no such argument (see the definition in mplhep)
it is only available in the yscale_legend function (here) which is used inside mpl_magic but the argument cannot be passed for mpl_magic directly
what we could do is fix the definition of mpl_magic for now like this
import matplotlib.pyplot as plt
from mplhep.plot import ylow, yscale_legend, yscale_anchored_text
# patch mplhep mpl_magic function to allow soft_fail=True
def mpl_magic(ax=None, info=True, soft_fail=True):
"""
Consolidate all ex-post style adjustments:
ylow
yscale_legend
"""
if ax is None:
ax = plt.gca()
if info:
pass
ax = ylow(ax)
ax = yscale_legend(ax, soft_fail=soft_fail)
return yscale_anchored_text(ax)
...
mpl_magic(ax=ax)
maybe we should also open an issue on the mplhep github issue?
Hi,
i noticed, that in the plotting script
plotdataMC.pythemplhep.mpl_magicfunction is usedBTVNanoCommissioning/scripts/plotdataMC.py
Lines 610 to 620 in a9f2508
however in mplhep there is no such argument (see the definition in mplhep)
it is only available in the
yscale_legendfunction (here) which is used insidempl_magicbut the argument cannot be passed formpl_magicdirectlywhat we could do is fix the definition of
mpl_magicfor now like thismaybe we should also open an issue on the mplhep github issue?