mplhep icon indicating copy to clipboard operation
mplhep copied to clipboard

ratio plot

Open lukasheinrich opened this issue 5 years ago • 9 comments

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

screenshot

lukasheinrich avatar Jun 03 '20 22:06 lukasheinrich

fwiw it seems to play nice with mplhep

screenshot

lukasheinrich avatar Jun 03 '20 22:06 lukasheinrich

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?

andrzejnovak avatar Jun 03 '20 22:06 andrzejnovak

hmm or better yet, two arrays like fig, ax, subax = ... then the shape is clear and you can iterate over both with zip

andrzejnovak avatar Jun 03 '20 22:06 andrzejnovak

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

nsmith- avatar Jan 03 '21 23:01 nsmith-

The problem with this is that the type of plots that ATLAS, LHCb, etc will accept for publication should look more like:

image

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 avatar Jun 05 '21 10:06 acampove

@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')

image

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()

image

andrzejnovak avatar Jun 05 '21 11:06 andrzejnovak

yeah this was just about being able to transparenttly arrange a set of ratio plots similar to subplots..

lukasheinrich avatar Jun 05 '21 11:06 lukasheinrich

@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.

acampove avatar Jun 05 '21 14:06 acampove

Hi @lukasheinrich could you share the code for this? I have been looking for something similar.

radiradev avatar Jan 14 '22 17:01 radiradev