Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The best way I have found for this was with the command <code>pylab.ion()</code> after you import pylab.</p> <p>Here is a script that does use <code>show()</code>, but which displays the different plots each time <code>pylab.draw()</code> is called, and which leaves the plot windows showing indefinitely. It uses simple input logic to decide when to close the figures (because using <code>show()</code> means pylab won't process clicks on the windows x button), but that should be simple to add to your gui as another button or as a text field.</p> <pre><code>import numpy as np import pylab pylab.ion() def get_fig(fig_num, some_data, some_labels): fig = pylab.figure(fig_num,figsize=(8,8),frameon=False) ax = fig.add_subplot(111) ax.set_ylim([0.1,0.8]); ax.set_xlim([0.1, 0.8]); ax.set_title("Quarterly Stapler Thefts") ax.pie(some_data, labels=some_labels, autopct='%1.1f%%', shadow=True); return fig my_labels = ("You", "Me", "Some guy", "Bob") # To ensure first plot is always made. do_plot = 1; num_plots = 0; while do_plot: num_plots = num_plots + 1; data = np.random.rand(1,4).tolist()[0] fig = get_fig(num_plots,data,my_labels) fig.canvas.draw() pylab.draw() print "Close any of the previous plots? If yes, enter its number, otherwise enter 0..." close_plot = raw_input() if int(close_plot) &gt; 0: pylab.close(int(close_plot)) print "Create another random plot? 1 for yes; 0 for no." do_plot = raw_input(); # Don't allow plots to go over 10. if num_plots &gt; 10: do_plot = 0 pylab.show() </code></pre> <p>By modifying the basic logic here, I can have it close windows and plot images consecutively to simulate playing a movie, or I can maintain keyboard control over how it steps through the movie.</p> <p><strong>Note:</strong> This has worked for me across platforms and seems strictly superior to the window canvas manager approach above, and doesn't require the 'TkAgg' option.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload