Skip to content

Conversation

aflaxman
Copy link
Contributor

@aflaxman aflaxman commented Jun 7, 2015

This one-line change addresses the issue of two copies of the traceplot appearing when using pm.traceplot(trace) in the ipython notebook, as described in #243. I know there is a simple workaround described there, but I would prefer this to "just work". I couldn't find any code where the returned fig was used, and if you have some, you can use plt.gcf() to get a reference to the current figure after calling pm.traceplot.

@jsalvatier
Copy link
Member

Oh yeah, that seems much better! Didn't know about that. The double plotting issue was annoying.

However, can you rebase your change on top of master instead of merging it?

@jsalvatier
Copy link
Member

You could also do

git checkout master
git checkout -b doubleplot
git cherry-pick c6ad789

@fonnesbeck
Copy link
Member

I'm not sure I'm on board with this one. A limitation with the PyMC 2 plots is that they are essentially unmodifiable because the functions do not return the figure object when plotted. The nice thing about the plots in PyMC 3 is that with the figure object returned, you can add elements to the plot that are non-standard. It may not sound like a big deal, but when it comes time to use figures for publications, etc., one often requires some customization. All you have to do to prevent double-plotting with the current implementation is to either assign the output to a variable, or use a semi-colon at the end of the call.

One alternative would be to allow for an axis argument on the plots to which one could pass a set of axes that could subsequently be modified.

@jsalvatier
Copy link
Member

hmm, good point. We could also have an argument that causes the value to be returned. Or we could always return it in a tuple or something so it doesn't get plotted the second time.

@jsalvatier
Copy link
Member

How do the plotting libraries work here? with %pylab inline plot seems to return a value but not get double plotted.

@fonnesbeck
Copy link
Member

Yeah, returning (fig, ax) should do the trick.

@fonnesbeck
Copy link
Member

See if the fix in double_plot_fix fits the bill.

@jsalvatier
Copy link
Member

The reason why out plots double plot and pylab plots dont is that we're returning a matplotlib.figure.Figure and they're returning objects like [matplotlib.lines.Line2D at 0x104b492c].

@jsalvatier
Copy link
Member

@fonnesbeck the double plot fix looks good to me, though you're overwriting some other changes.

@aflaxman
Copy link
Contributor Author

aflaxman commented Jun 7, 2015

@fonnesbeck your double_plot_fix works fine for me. Happy to have that instead, if you think the returned stuff will be of use.

@fonnesbeck
Copy link
Member

@jsalvatier that's bizarre. Not sure how that happened. Will fix.

@fonnesbeck
Copy link
Member

Closing this in favor of #745

@fonnesbeck fonnesbeck closed this Jun 7, 2015
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

Successfully merging this pull request may close these issues.

3 participants