-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fix for double-plotting of some output #745
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
Conversation
…ing to autocorrplot
looks good to me. |
I'm not clear on what this is fixing, but I think all plots should return a figure, as suggested by John Hunter. The figure contains a reference to the axes, so it can be retrieved if needed. |
Sorry, hadn't caught up on the other issues yet. I still don't vote for the change, but I understand what it is fixing. |
This change returns the figure and the axes, so this is not breaking Hunter's Rule, and it prevents redundant plotting of the figure in the notebook. We could return a list containing the figure only (or the axes only), which would be consistent with Pandas or Matplotlib if this is preferable. |
Is it possible to get back the axes from the figure? On Sun, Jun 7, 2015 at 7:56 PM, Chris Fonnesbeck notifications@github.com
|
He suggests to always return just a figure, but either way, his main points were to 1) always return a consistent thing, and 2) allow the user to pass in their own ax or fig instance (depending on if there all multiple subplots). With these changes, pymc plotting functions do pretty well with 1. (I think forestplot is the only non-helper plotting function that doesn't return this.) Our plotting functions don't do great with 2, but that's not related to this issue.
Yes, this is reasonable. I'm not a big fan of these changes because 1) I'm used to the idea of always returning a figure, 2) I'm fine with avoiding the double figure by making sure to assign back (or use a semicolon), 3) I'm probably not as heavy of a notebook user as other people. None of these seem like great reasons to oppose the change that fixes an annoyance for other people, while keeping a consistent return value. So, on second thought, I'm for it. |
Yes, through |
Then lets return the figure in a list (which seems to be what matplotlib does). I think that's the most consistent thing and gets us most of what we want. |
I was aiming for (2) as well, but for the trace plot at least, a 2-panel plot is required, so it is a little unusual relative to a standard matplotlib plot. I suppose we could put in a check for a set of 2 axes. |
In the current iteration, all plots accept/receive plot axes (or GridSpec, in the case of |
We cool with this? |
I think the idea is that if there are multiple subplots, the optional argument can be a figure instance that you attach subplots to.
You can access the figure from axes with
I'm ok with any consistent return value. I'm still not sure what circumstances are causing the double plot. I can't reproduce it with ipython notebook version 3.1.0 (using '%matplotlib inline') and matplotlib's master. I think that as long as the code doesn't call any pyplot functions aside from the initial figure creation (forestplot is the biggest offender here), nothing should be drawn, so you shouldn't see a double plot when returning a figure. Anyway, with some combination of versions and setups, people are seeing this, so changing the return value to something else that avoids the issue seems like a good idea. |
I'm going to go ahead an merge this, then, since it is consistent and it works. We can revisit later if this solution causes problems. |
Fix for double-plotting of some output
Main plots return tuple of figure and axes.