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

Reply via email to