From: Rune Allnor on
On 17 Jan, 13:16, "Bruno Luong" <b.lu...(a)fogale.findmycountry> wrote:
> workaholic <liua...(a)gmail.com> wrote in message <288f2be6-c093-482a-a36a-9708edcff...(a)a6g2000yqm.googlegroups.com>...
> > I want to show a batch of data in an animation in plot,combining with
> > 'drawnow' and 'refreshdata' command. But I found that the axis is
> > constantly changing accordingly. How can I fix the axis?
>
> Use AXIS command to force the axis at given fixed limits.

If you still see changes in the axes (although that's
highly improbable) add

set(gca,'dataaspectratio',[1 1 1])

Rune
From: workaholic on
On Jan 18, 9:49 pm, "Jos (10584) " <#10...(a)fileexchange.com> wrote:
> workaholic <liua...(a)gmail.com> wrote in message <bbb5b046-b3ca-4044-940a-42ff66c0a...(a)f12g2000yqn.googlegroups.com>...
> > On 17 Jan., 11:53, "Jan Simon" <matlab.THIS_Y...(a)nMINUSsimon.de>
> > wrote:
> > > Dear workaholic!
>
> > > > I want to show a batch of data in an animation in plot,combining with
> > > > 'drawnow' and 'refreshdata' command. But I found that the axis is
> > > > constantly changing accordingly. How can I fix the axis?
>
> > > I cannot understand the question. What part/kind/entity of the axis is changing accordingly to what?
> > > Do you look for the AXES objects property 'NextPlot' and set it to 'add'?
>
> > > I suggest, you post the small part of your program, which reproduces the problem.
>
> > > Kind regards, Ja
>
> > My code is below:
>
> > h = plot(xpos,ypos,'XDataSource','xpos','YDataSource','ypos');
>
> > for k = 1:tlen
>
> > % pos is a data pool
>
> >      xpos = pos(k,:);
> >     ypos = pos(k+1,:);
>
> >    refreshdata(h,'caller') % Evaluate y in the function workspace
> >    drawnow; pause(.1)
> > end
>
> > I tried to put some code before the plot command like axis([xmin xmax
> > ymin ymax]) but it does not work at all, the coordinate of the plot is
> > changing at every iteration. How can I deal with it?
> > Thanks
>
> Here is an alternative, using SET instead of refreshdata, so not all sources are refreshed on each loop:
>
> % data (Lissajous curves)
> t = linspace(0,2*pi,50) ;
> x = 2 * sin(3*t) ;
> y = 3 * sin(4*t) ;
>
> figure % force view
> h = plot(x(1),y(1),'b-',x(1),y(1),'ro') ;
> pause(0.5) ;
> axis([-3 3 -4 14]) ; % specify a strange axis, that is not changed
>
> for ii=2:numel(x),
>   % update plots
>   set(h(1),'xdata',x(1:ii),'ydata',y(1:ii)) ;
>   set(h(2),'xdata',x(ii),'ydata',y(ii)) ;
>   pause(0.1) ;  drawnow ; % visibility
> end
>
> hth
> Jos

Thanks a lot, I put axis() command in each iteratinon, then it works.