draw() doesn't always force draw on qt4?

Hello,

I'm using today's svn source and I'm surprised that the following loop
does not get redrawn 10 times.

  for it in range( 10 ):
      plot( arange( it ) )
      draw()
      raw_input();

That is, within a 'ipython -pylab' session. Is this really a question
for the ipython folks? Or am I missing something here?

Thank you,
Glen Mabey

Hello Glen,

I'm not sure, but maybe it would help to use
  ax = subplot(111)
and
  ax.plot(arange(it))
instead of plot(arange(it))
or to call a second draw() after plotting.

regards Matthias

···

On Wednesday 23 April 2008 20:49:46 Glen W. Mabey wrote:

Hello,

I'm using today's svn source and I'm surprised that the following loop
does not get redrawn 10 times.

  for it in range( 10 ):
      plot( arange( it ) )
      draw()
      raw_input();

That is, within a 'ipython -pylab' session. Is this really a question
for the ipython folks? Or am I missing something here?

Thank you,
Glen Mabey

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/java
one _______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

That also surprises me, but it is not specific to the qt4 backend, nor to
recent changes in svn. I see similar behavior with the gtkcairo backend in
0.91.2. Unfortunately, I dont have time to look into it further.

Darren

···

On Wednesday 23 April 2008 02:49:46 pm Glen W. Mabey wrote:

Hello,

I'm using today's svn source and I'm surprised that the following loop
does not get redrawn 10 times.

  for it in range( 10 ):
      plot( arange( it ) )
      draw()
      raw_input();

That is, within a 'ipython -pylab' session. Is this really a question
for the ipython folks? Or am I missing something here?

Can you explain what is happening in your code? First off, in pylab
mode this should be drawn 20 times, because in interactive mode plot
forces a draw and draw does too, so you should get 20 draws.
Secondly, ipython in pylab mode for some backends (Qt, GTK and WX) run
the GUI mainloop in a thread and I am not sure what will happen with
the "raw_input" which you expect to be blocking (it is not supported).

Folks have had various successes with getting blocking input for
matplotlib in interactive sessions, but Gael has made the most
progress. See the ginput function in svn

  -- "ginput'' in pylab or matplotlib.pyplot

  -- matplotlib.figure.Figure.ginput in the API

from pylab import arange, plot, sin, ginput, show
t = arange(10)
plot(t, sin(t))
print "Please click"
x = ginput(3, verbose=True)
show()

JDH

···

On Wed, Apr 23, 2008 at 1:49 PM, Glen W. Mabey <Glen.Mabey@...943...> wrote:

Hello,

I'm using today's svn source and I'm surprised that the following loop
does not get redrawn 10 times.

  for it in range( 10 ):
      plot( arange( it ) )
      draw()
      raw_input();

That is, within a 'ipython -pylab' session. Is this really a question
for the ipython folks? Or am I missing something here?

> Hello,
>
> I'm using today's svn source and I'm surprised that the following loop
> does not get redrawn 10 times.
>
> for it in range( 10 ):
> plot( arange( it ) )
> draw()
> raw_input();
>
> That is, within a 'ipython -pylab' session. Is this really a question
> for the ipython folks? Or am I missing something here?

Can you explain what is happening in your code? First off, in pylab
mode this should be drawn 20 times, because in interactive mode plot
forces a draw and draw does too, so you should get 20 draws.
Secondly, ipython in pylab mode for some backends (Qt, GTK and WX) run
the GUI mainloop in a thread and I am not sure what will happen with
the "raw_input" which you expect to be blocking (it is not supported).

Hi John,

I guess it was for that reason (that the GUI mainloop runs in a
different thread) that I was expecting the draw to succeed.

Folks have had various successes with getting blocking input for
matplotlib in interactive sessions, but Gael has made the most
progress. See the ginput function in svn

  -- "ginput'' in pylab or matplotlib.pyplot

  -- matplotlib.figure.Figure.ginput in the API

from pylab import arange, plot, sin, ginput, show
t = arange(10)
plot(t, sin(t))
print "Please click"
x = ginput(3, verbose=True)
show()

After looking at that code, I don't immediately see how a similar
approach could be used for retrieving keyboard input from the user while
still allowing MPL drawing in the same loop. But thank you for pointing
out that example.

Best Regards,
Glen Mabey

···

On Thu, Apr 24, 2008 at 08:59:32AM -0500, John Hunter wrote:

On Wed, Apr 23, 2008 at 1:49 PM, Glen W. Mabey <Glen.Mabey@...943...> wrote: