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

[FEATURE] Add high level API for ratio plot and pull plot to be plotted standalone #192

Open
matthewfeickert opened this issue Apr 12, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@matthewfeickert
Copy link
Member

matthewfeickert commented Apr 12, 2021

Describe the problem, if any, that your feature request is related to

A clear and concise description of what the problem is.

This might be getting into Issue #117 territory, but not that PR #161 there is the ability to make both ratio plots and pull plots with the .plot_ratio and .plot_pull APIs, but these both plot the participants of the fit or ratio on the top (main) axis and then the ratio or the pulls on a bottom (subplot) axis. There are times when one wants to be able to highlight features of the ratio / pulls by itself and in those situations having it on its own figure it desirable. As the matplotlib API is setup to keep you from trying to copy axis objects around (c.f. details) it would be useful to have an API to plot the subplots by themselves.

Details:

Conversation on IRIS-HEP Slack on 2021-04-12:

@matthewfeickert: From my Stack Overflow searching tonight I think the answer is "no, because matplotlib intends for axes objects to be inherently linked to a singular figure.", but I'll ask the matplotlib experts here: is there any non-super-hacky-breaking-the-API way to take a subplot that you've made and then copy it to a new figure as the only subplot if you wanted to look at it in more detail or blow it up to show some feature. I think the answer is "no, please just replot it".

Thomas Caswell: correct, Axes are deeply tied to the Figure they are in (as we need transforms that go from data space -> screen space). In principle it should be possible to move Axes between figures, however in practice we do not have enough control of all of the connections between the Axes and the Figure to be sure we can do it correctly so we raise if you try!
The best approach is to plot it again (and make sure you write your self enough helper functions that it is easy 😉 )

Support for this already exists in the form of

def plot_ratio_array(

and

def plot_pull_array(

but it requires that the user do a bit of work (what is currently most of the logic in

def _plot_ratiolike(

) to get the ratio or pull np.ndarray to then plot.

Describe the feature you'd like

A refactoring of the .plot_ratio and .plot_pull APIs to allow for a user to still have the ratio, fit, or pull calculations performed for them but then only plot the subplot of the ratio or pulls.

I'm happy to help on this, once there is a consensus on what to do.

Describe alternatives, if any, you've considered

As mentioned above, instead of doing this refactor in hist migrate all of it to mplhep as talked about in Issue #117.

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

No branches or pull requests

2 participants