Octave plot points as animation

I have the following octave script,

TOTAL_POINTS = 100;
figure(1)

for i=1:TOTAL_POINTS
   randX = rand(1); 
   randY = rand(1);

   scatter(randX, randY);
   hold on; 
endfor

When I run this with octave script.m, I get nothing. When I add a line pauseto the end of this script, it works, but I see the graph only after all points have been plotted 100.

I want to see a graph by points. Not after I built every point.

PS: I have Ubuntu.

+4
source share
1 answer

Try adding drawnowat the end of the iteration. At least it works in Matlab. This forces the interpreter to clear the graphic event queue.

pause , drawnow (pause ). .

:

  • hold on . , .
  • , .

:

TOTAL_POINTS = 100;
figure(1)
hold on; 
axis([0 1 0 1]) %// set axis
axis manual %// prevent axis from auto-scaling
for i=1:TOTAL_POINTS
   randX = rand(1); 
   randY = rand(1);
   scatter(randX, randY);
   pause(.1) %// pause 0.1 seconds to slow things down
   drawnow
endfor
+6

Source: https://habr.com/ru/post/1544491/


All Articles