Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ratio plot #153

Open
lukasheinrich opened this issue Jun 3, 2020 · 9 comments
Open

ratio plot #153

lukasheinrich opened this issue Jun 3, 2020 · 9 comments

Comments

@lukasheinrich
Copy link

lukasheinrich commented Jun 3, 2020

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
Copy link
Author

lukasheinrich commented Jun 3, 2020

fwiw it seems to play nice with mplhep

screenshot

@andrzejnovak
Copy link
Member

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
Copy link
Member

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

@nsmith-
Copy link

nsmith- commented Jan 3, 2021

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

@acampove
Copy link

acampove commented Jun 5, 2021

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.

@andrzejnovak
Copy link
Member

@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

@lukasheinrich
Copy link
Author

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

@acampove
Copy link

acampove commented Jun 5, 2021

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

@radiradev
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants