cannot plot in loops with matplotlib 0.99. 0.98 works fine

Hi all

with matplotlib 0.98.5.3 this script will draw new lines as the scrips is
running:

from pylab import *
x = arange(0,2*pi,0.01)
for i in arange(1,20):
  
  y=sin(x+i)
  plot(x,y) # update the data
  show()

with matplotlib 0.99, the exact same script runs to the end without plotting
and then plots all the lines. This is just a trivial example but for some
applications it is useful to monitor the evolution of curves as the script
is running - allows me to update parameters if something diverges.
Any idea why there is such a difference between 0.98.5.3 and 0.99 ??

···

--
View this message in context: http://www.nabble.com/cannot-plot-in-loops-with-matplotlib-0.99.-0.98-works-fine-tp25320454p25320454.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

I presume you're running that script in interactive shell?
Try draw() instead of show().

Regards,

-JJ

···

On Sun, Sep 6, 2009 at 3:06 PM, tva<tva@...2770...> wrote:

Hi all

with matplotlib 0.98.5.3 this script will draw new lines as the scrips is
running:

from pylab import *
x = arange(0,2*pi,0.01)
for i in arange(1,20):

   y=sin\(x\+i\)
   plot\(x,y\)  \# update the data
   show\(\)

with matplotlib 0.99, the exact same script runs to the end without plotting
and then plots all the lines. This is just a trivial example but for some
applications it is useful to monitor the evolution of curves as the script
is running - allows me to update parameters if something diverges.
Any idea why there is such a difference between 0.98.5.3 and 0.99 ??
--
View this message in context: http://www.nabble.com/cannot-plot-in-loops-with-matplotlib-0.99.-0.98-works-fine-tp25320454p25320454.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Thanks JJ, but unfortunately this is not the solution. draw() gives the same
result. - and I am running this as a script (running it from ipython shell).

Any clue?

Jae-Joon Lee wrote:

···

I presume you're running that script in interactive shell?
Try draw() instead of show().

Regards,

-JJ

On Sun, Sep 6, 2009 at 3:06 PM, tva<tva@...2770...> wrote:

Hi all

with matplotlib 0.98.5.3 this script will draw new lines as the scrips is
running:

from pylab import *
x = arange(0,2*pi,0.01)
for i in arange(1,20):

   y=sin\(x\+i\)
   plot\(x,y\)  \# update the data
   show\(\)

with matplotlib 0.99, the exact same script runs to the end without
plotting
and then plots all the lines. This is just a trivial example but for some
applications it is useful to monitor the evolution of curves as the
script
is running - allows me to update parameters if something diverges.
Any idea why there is such a difference between 0.98.5.3 and 0.99 ??
--
View this message in context:
http://www.nabble.com/cannot-plot-in-loops-with-matplotlib-0.99.-0.98-works-fine-tp25320454p25320454.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008
30-Day
trial. Simplify your report design, integration and deployment - and
focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008
30-Day
trial. Simplify your report design, integration and deployment - and focus
on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

--
View this message in context: http://www.nabble.com/cannot-plot-in-loops-with-matplotlib-0.99.-0.98-works-fine-tp25320454p25326025.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Any idea why there is such a difference between
0.98.5.3 and 0.99 ??

Drawing the whole figure once, when no further Python input is available, is much more efficient than drawing after each plot() command. For some figures, matplotlib 0.98.5.3 becomes extremely slow.

Thanks JJ, but unfortunately this is not the solution.
draw() gives the same result. - and I am running this
as a script (running it from ipython shell).

The problem in your script is that the event loop never kicks in. Unfortunately, Python has no support for event loops in general, which makes this hard to solve. One option is to use raw_input() between calls to plot(), but then each time you have to hit <enter> to get the script to proceed.

--Michiel.

···

--- On Mon, 9/7/09, tva <tva@...2770...> wrote:

From: tva <tva@...2770...>
Subject: Re: [Matplotlib-users] cannot plot in loops with matplotlib 0.99. 0.98 works fine
To: matplotlib-users@lists.sourceforge.net
Date: Monday, September 7, 2009, 3:17 AM

Thanks JJ, but unfortunately this is not the solution.
draw() gives the same
result. - and I am running this as a script (running it
from ipython shell).

Any clue?

Jae-Joon Lee wrote:
>
> I presume you're running that script in interactive
shell?
> Try draw() instead of show().
>
> Regards,
>
> -JJ
>
>
> On Sun, Sep 6, 2009 at 3:06 PM, tva<tva@...2770...> > wrote:
>>
>> Hi all
>>
>> with matplotlib 0.98.5.3 this script will draw new
lines as the scrips is
>> running:
>>
>> from pylab import *
>> x = arange(0,2*pi,0.01)
>> for i in arange(1,20):
>>
>> y=sin(x+i)
>> plot(x,y) # update the data
>> show()
>>
>>
>> with matplotlib 0.99, the exact same script runs
to the end without
>> plotting
>> and then plots all the lines. This is just a
trivial example but for some
>> applications it is useful to monitor the evolution
of curves as the
>> script
>> is running - allows me to update parameters if
something diverges.
>> Any idea why there is such a difference between
0.98.5.3 and 0.99 ??
>> --
>> View this message in context:
>> http://www.nabble.com/cannot-plot-in-loops-with-matplotlib-0.99.-0.98-works-fine-tp25320454p25320454.html
>> Sent from the matplotlib - users mailing list
archive at Nabble.com.
>>
>>
>>
------------------------------------------------------------------------------
>> Let Crystal Reports handle the reporting - Free
Crystal Reports 2008
>> 30-Day
>> trial. Simplify your report design, integration
and deployment - and
>> focus on
>> what you do best, core application coding.
Discover what's new with
>> Crystal Reports now. http://p.sf.net/sfu/bobj-july
>> _______________________________________________
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> matplotlib-users List Signup and Options
>>
>
>
------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free
Crystal Reports 2008
> 30-Day
> trial. Simplify your report design, integration and
deployment - and focus
> on
> what you do best, core application coding. Discover
what's new with
> Crystal Reports now. http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> matplotlib-users List Signup and Options
>
>

--
View this message in context: http://www.nabble.com/cannot-plot-in-loops-with-matplotlib-0.99.-0.98-works-fine-tp25320454p25326025.html
Sent from the matplotlib - users mailing list archive at
Nabble.com.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal
Reports 2008 30-Day
trial. Simplify your report design, integration and
deployment - and focus on
what you do best, core application coding. Discover what's
new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Hi Michiel

thanks, but does that explain why the script works smoothly in 0.98.6 and
earlier versions?
Plotting all the curves at the end of the script is certainly possible, but
it is a severe reduction of the functionallity. given the fact that it works
so well in earlier versions of matplotlib, it seems like a bug in
matplotlib...?

Michiel de Hoon wrote:

···

Any idea why there is such a difference between
0.98.5.3 and 0.99 ??

Drawing the whole figure once, when no further Python input is available,
is much more efficient than drawing after each plot() command. For some
figures, matplotlib 0.98.5.3 becomes extremely slow.

Thanks JJ, but unfortunately this is not the solution.
draw() gives the same result. - and I am running this
as a script (running it from ipython shell).

The problem in your script is that the event loop never kicks in.
Unfortunately, Python has no support for event loops in general, which
makes this hard to solve. One option is to use raw_input() between calls
to plot(), but then each time you have to hit <enter> to get the script to
proceed.

--Michiel.

--- On Mon, 9/7/09, tva <tva@...2770...> wrote:

From: tva <tva@...2770...>
Subject: Re: [Matplotlib-users] cannot plot in loops with matplotlib
0.99. 0.98 works fine
To: matplotlib-users@lists.sourceforge.net
Date: Monday, September 7, 2009, 3:17 AM

Thanks JJ, but unfortunately this is not the solution.
draw() gives the same
result. - and I am running this as a script (running it
from ipython shell).

Any clue?

Jae-Joon Lee wrote:
>
> I presume you're running that script in interactive
shell?
> Try draw() instead of show().
>
> Regards,
>
> -JJ
>
>
> On Sun, Sep 6, 2009 at 3:06 PM, tva<tva@...2770...> >> wrote:
>>
>> Hi all
>>
>> with matplotlib 0.98.5.3 this script will draw new
lines as the scrips is
>> running:
>>
>> from pylab import *
>> x = arange(0,2*pi,0.01)
>> for i in arange(1,20):
>>
>> y=sin(x+i)
>> plot(x,y) # update the data
>> show()
>>
>>
>> with matplotlib 0.99, the exact same script runs
to the end without
>> plotting
>> and then plots all the lines. This is just a
trivial example but for some
>> applications it is useful to monitor the evolution
of curves as the
>> script
>> is running - allows me to update parameters if
something diverges.
>> Any idea why there is such a difference between
0.98.5.3 and 0.99 ??
>> --
>> View this message in context:
>>
http://www.nabble.com/cannot-plot-in-loops-with-matplotlib-0.99.-0.98-works-fine-tp25320454p25320454.html
>> Sent from the matplotlib - users mailing list
archive at Nabble.com.
>>
>>
>>
------------------------------------------------------------------------------
>> Let Crystal Reports handle the reporting - Free
Crystal Reports 2008
>> 30-Day
>> trial. Simplify your report design, integration
and deployment - and
>> focus on
>> what you do best, core application coding.
Discover what's new with
>> Crystal Reports now. http://p.sf.net/sfu/bobj-july
>> _______________________________________________
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> matplotlib-users List Signup and Options
>>
>
>
------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free
Crystal Reports 2008
> 30-Day
> trial. Simplify your report design, integration and
deployment - and focus
> on
> what you do best, core application coding. Discover
what's new with
> Crystal Reports now. http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> matplotlib-users List Signup and Options
>
>

--
View this message in context:
http://www.nabble.com/cannot-plot-in-loops-with-matplotlib-0.99.-0.98-works-fine-tp25320454p25326025.html
Sent from the matplotlib - users mailing list archive at
Nabble.com.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal
Reports 2008 30-Day
trial. Simplify your report design, integration and
deployment - and focus on
what you do best, core application coding. Discover what's
new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008
30-Day
trial. Simplify your report design, integration and deployment - and focus
on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

--
View this message in context: http://www.nabble.com/cannot-plot-in-loops-with-matplotlib-0.99.-0.98-works-fine-tp25320454p25327845.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Problem solved. The backend was set to Qt4Agg. Once set to TkAgg everything
works.
I don't get it but it works..........

tva wrote:

···

Hi Michiel

thanks, but does that explain why the script works smoothly in 0.98.6 and
earlier versions?
Plotting all the curves at the end of the script is certainly possible,
but it is a severe reduction of the functionallity. given the fact that it
works so well in earlier versions of matplotlib, it seems like a bug in
matplotlib...?

Michiel de Hoon wrote:

Any idea why there is such a difference between
0.98.5.3 and 0.99 ??

Drawing the whole figure once, when no further Python input is available,
is much more efficient than drawing after each plot() command. For some
figures, matplotlib 0.98.5.3 becomes extremely slow.

Thanks JJ, but unfortunately this is not the solution.
draw() gives the same result. - and I am running this
as a script (running it from ipython shell).

The problem in your script is that the event loop never kicks in.
Unfortunately, Python has no support for event loops in general, which
makes this hard to solve. One option is to use raw_input() between calls
to plot(), but then each time you have to hit <enter> to get the script
to proceed.

--Michiel.

--- On Mon, 9/7/09, tva <tva@...2770...> wrote:

From: tva <tva@...2770...>
Subject: Re: [Matplotlib-users] cannot plot in loops with matplotlib
0.99. 0.98 works fine
To: matplotlib-users@lists.sourceforge.net
Date: Monday, September 7, 2009, 3:17 AM

Thanks JJ, but unfortunately this is not the solution.
draw() gives the same
result. - and I am running this as a script (running it
from ipython shell).

Any clue?

Jae-Joon Lee wrote:
>
> I presume you're running that script in interactive
shell?
> Try draw() instead of show().
>
> Regards,
>
> -JJ
>
>
> On Sun, Sep 6, 2009 at 3:06 PM, tva<tva@...2770...> >>> wrote:
>>
>> Hi all
>>
>> with matplotlib 0.98.5.3 this script will draw new
lines as the scrips is
>> running:
>>
>> from pylab import *
>> x = arange(0,2*pi,0.01)
>> for i in arange(1,20):
>>
>> y=sin(x+i)
>> plot(x,y) # update the data
>> show()
>>
>>
>> with matplotlib 0.99, the exact same script runs
to the end without
>> plotting
>> and then plots all the lines. This is just a
trivial example but for some
>> applications it is useful to monitor the evolution
of curves as the
>> script
>> is running - allows me to update parameters if
something diverges.
>> Any idea why there is such a difference between
0.98.5.3 and 0.99 ??
>> --
>> View this message in context:
>>
http://www.nabble.com/cannot-plot-in-loops-with-matplotlib-0.99.-0.98-works-fine-tp25320454p25320454.html
>> Sent from the matplotlib - users mailing list
archive at Nabble.com.
>>
>>
>>
------------------------------------------------------------------------------
>> Let Crystal Reports handle the reporting - Free
Crystal Reports 2008
>> 30-Day
>> trial. Simplify your report design, integration
and deployment - and
>> focus on
>> what you do best, core application coding.
Discover what's new with
>> Crystal Reports now. http://p.sf.net/sfu/bobj-july
>> _______________________________________________
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> matplotlib-users List Signup and Options
>>
>
>
------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free
Crystal Reports 2008
> 30-Day
> trial. Simplify your report design, integration and
deployment - and focus
> on
> what you do best, core application coding. Discover
what's new with
> Crystal Reports now. http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> matplotlib-users List Signup and Options
>
>

--
View this message in context:
http://www.nabble.com/cannot-plot-in-loops-with-matplotlib-0.99.-0.98-works-fine-tp25320454p25326025.html
Sent from the matplotlib - users mailing list archive at
Nabble.com.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal
Reports 2008 30-Day
trial. Simplify your report design, integration and
deployment - and focus on
what you do best, core application coding. Discover what's
new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008
30-Day
trial. Simplify your report design, integration and deployment - and
focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

--
View this message in context: http://www.nabble.com/cannot-plot-in-loops-with-matplotlib-0.99.-0.98-works-fine-tp25320454p25333552.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

I think an explicit call of draw() in the interactive mode (e.g. with
ipython -pylab) should update the figure canvas immediately. And this
is the behavior I currently observe with Gtk and Wx backend. If the
Qt4 backend behaves differently, I guess this is a bug. I don't have
the qt4 backend installed, and I hope other developers take a look.

-JJ

···

On Mon, Sep 7, 2009 at 1:02 PM, tva<tva@...2770...> wrote:

Problem solved. The backend was set to Qt4Agg. Once set to TkAgg everything
works.
I don't get it but it works..........