I don't have a good answer to this and have had to implement such a
thing in an outstanding pull request (in my case, I have a figure
which has been un-pickled and needs re-attaching to pyplot).

My proposed mechanism goes something like:


figure = matplotlib.figure.Figure(...)

import matplotlib.pyplot as plt

mgr = plt._backend_mod.new_figure_manager_given_figure(num, self)



Obviously this doesn't even exist on master yet, so if you need this
functionality from a version before this you will have to reverse
engineer the pyplot.figure function.

HTH,



On 29 July 2012 13:12, Anton Akhmerov <anton.akhme...@gmail.com> wrote:
> Hi,
>
> I am writing a module which should, among other things, output images, and it
> should work both in interactive mode and when imported as a script.
>
> In order for the plotting behavior to be clean, I would like to prepare the
> figure separate from pyplot. The reason for this, is that the figure is drawn 
> in
> a non-interactive loop, and I don't want to show all the steps as they go.
> Moreover, for some reason with ipython inline backend the figure is rendered
> twice for no obvious reason. So the preferred behavior of my plotting function
> (when pyplot output is requested) should be similar to:
>
> fig = matplotlib.figure.Figure()
> ax = fig.add_subplot(111)
> ax.plot([1,2,3])
> matplotlib.pyplot.<ADD_FIGURE>(fig)
>
> The best approximation to this that I was able to find so far is to use the
> following dirty hack (although none of the attributes I use are _private!):
>
> f = plt.figure()
> fig.canvas = f.canvas
> f.canvas.figure = fig
>
> However this is still problematic: if the interactive mode is on, then 
> rendering
> of the figure will still be called after these two attribute. Moreover in
> IPython notebook without inline plotting it will result in an opened GUI 
> window,
> but GUI mainloop not running.
>
> So here's my question: what's the best way to achieve the behavior that I 
> want?
>
> Thank you,
> Anton
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to