help-octave
[Top][All Lists]
Advanced

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

Re: Flickering and drawnow plot


From: Pantxo
Subject: Re: Flickering and drawnow plot
Date: Mon, 16 May 2016 00:18:52 -0700 (PDT)

RT wrote
> I'm trying to animate two 3d plots at the same time but I keep getting
> flickering does anyone now of a workaround or how to prevent the
> flickering?
> 
> See code below:  I'm using octave 4.0 on ubuntu 16.04 64bit
> 
> k1 = 1; %how many times you want wave to oscillate in x-dir
> k2 = 1; %how many times you want wave to oscillate in y-dir
> u = linspace(-pi,pi,30); %how many segments
> v = linspace(-pi,pi,30); % how many segments
> [x,y] = meshgrid(u,v);  %how many segments
> 
> w_len=max(length(x))
> 
> for ii=1:180
>   z=sin(k2*x+(ii)*pi/180);
>   z2=-sin(k2*y+(ii)*pi/180);
> 
>   surf(x,y,z);
>   drawnow
>   surf(x,y,z2);
>   drawnow
> 
>   pause(.001)
> 
> end
> 
> _______________________________________________
> Help-octave mailing list

> Help-octave@

> https://lists.gnu.org/mailman/listinfo/help-octave

You can also bind surface "zdata" to a given variable using "zdatasource"
and then use "refreshdata ()" to update plots when the variable has changed.
Something like:

  ...
  w_len=max(length(x))

  z = z2 = x;
  surf (x, y, z, "zdatasource", "z");
  hold on
  surf (x, y, z2, "zdatasource", "z2");
  for ii=1:180
    z=sin(k2*x+(ii)*pi/180);
    z2=-sin(k2*y+(ii)*pi/180);
    refreshdata ()

    pause(.001)

  end


Pantxo



--
View this message in context: 
http://octave.1599824.n4.nabble.com/Flickering-and-drawnow-plot-tp4676939p4676979.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

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