mplhep
mplhep copied to clipboard
ratio plot
Hi,
for some of my work I created a somehwat drop-in-ish replacement for plt.subplots but for ratio plots.. is this something that'd be interesting for this package?
I didn't immediatly see functionality for this in mplhep yet
cc @kratsg @matthewfeickert
fwiw it seems to play nice with mplhep
That's kinda neat. I collect similar helper functions in mplhep.plot as well, though they're not well documented yet. A PR is welcome! One thing that feels kinda weird is having the subplot as a dict with main and aux could it be a tuple instead?
hmm or better yet, two arrays like fig, ax, subax = ... then the shape is clear and you can iterate over both with zip
There is a ratioplot utility in coffea that might be able to be ported over, as was done for the others: https://coffeateam.github.io/coffea/api/coffea.hist.plotratio.html
The problem with this is that the type of plots that ATLAS, LHCb, etc will accept for publication should look more like:

I won't use anything that looks radically different because at the end the collaboration will make us change it so that it looks like the standard style. For which I would end up using the old ROOT way of doing things anyway.
@acampove I am not sure I follow. This issue is about automating layout for multiple subplots. The styling is separate and fairly straightforward.
import matplotlib.pyplot as plt
import mplhep as hep
import numpy as np
hists = [np.histogram(np.random.normal(i, 2, 10000), bins=np.linspace(0, 10, 50)) for i in [4, 5, 6]]
hep.histplot(hists[:2])
hep.histplot(hists[2], histtype='errorbar')

hep.style.use('ATLAS')
hep.histplot(hists[:2], color=['black', 'red'], label=['mc1', 'mc2'])
hep.histplot(hists[2], histtype='errorbar', color='k', yerr=True, label='Data')
plt.legend()

yeah this was just about being able to transparenttly arrange a set of ratio plots similar to subplots..
@andrzejnovak Yes, I did not know that switching from that matplotlib style to an ATLAS style was that simple and that the layout was so easy to change.
Hi @lukasheinrich could you share the code for this? I have been looking for something similar.