help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: refreshdata produces unexpected results


From: David Bateman
Subject: Re: refreshdata produces unexpected results
Date: Mon, 22 Mar 2010 20:44:11 +0100
User-agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090706)

address@hidden wrote:
Hi,

the refreshdata command, intended to update plot data selectively, doesn't work as I'd expect.
It seems all graphics data is redrawn, not only changed data.
Consider the following example:

x = 0:0.1:10;
y1 = sin (x);
y2 = cos (x);
subplot ( 1, 2, 1) ;
plot (x, y1, "ydatasource", "y1");
subplot ( 1, 2, 2) ;
plot (x, y2, "color",[1, 0, 0], "ydatasource", "y2");
for i = 1 : 30
   y1 = sin (x + 0.1 * i);
   y2 = cos (x + 0.1 * i);
   refreshdata(gcf(), "caller");
   pause(0.01);
 endfor

The plot window is redrawn completely with every call to refreshdata.
The result is a very jerky, jolty diagram instead of a smooth animation.
The following example tries to do the same thing, avoiding the overhead of the refreshdata command. However, the result is only a moderate speed-up leaving you
with basically the same situation

x = 0:0.1:10;
y1 = sin (x);
y2 = cos (x);
subplot ( 1, 2, 1) ;
plt1 = plot (x, y1 );
subplot ( 1, 2, 2) ;
plt2 = plot (x, y2, "color",[1, 0, 0]);
for i = 1 : 30
   y1 = sin (x + 0.1 * i);
   y2 = cos (x + 0.1 * i);
set ( plt1, "ydata", y1 ); set ( plt2, "ydata", y2 ); pause(0.01)
endfor

This behaviour is the same on ;-) and on linux.

Anything  I got wrong or misunderstood ?
Could the gnuplot config file be in error or in need for modifications ?

Any idea, how a smooth animation could be achieved ?

adTHANKSvance, Claus

From the way the gnuplot interface is implemented, refreshdata has to redraw an entire figure each time as gnuplot had no way to do a "replot" from a stream. In fact it seems that the __go_draw_figure__ function doesn't check the __modified__ property of the figure and so all figures are redrawn even though probably only figures that are modified should be redrawn

D.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]