help-octave
[Top][All Lists]
Advanced

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

changing xdata in stem plot


From: pvpage
Subject: changing xdata in stem plot
Date: Tue, 11 Jun 2013 08:52:58 -0700 (PDT)

Unlike plot(), when I want to change xdata and ydata in a stem (or stairs), I
have to issue set(hs,'xdata'...) two times. 

A clumsy solution is the try..catch statement. The following snippet works
fine in Octave 3.6.4 VS2010 with fltk.

hf= figure;
N = 20;
x = 0:(N-1);
y = rand(1,N);
hs=stem(x(1),y(1));
% hs=stairs(x(1),y(1));
% hs=plot(x(1),y(1));
set(gca(), 'xlim',[1,N], 'ylim',[0,1]);
for k=2:N
  pause(0.2);
  try  
    set(hs, 'xdata',x(1:k), 'ydata', y(1:k));
  catch
    set(hs, 'xdata',x(1:k), 'ydata', y(1:k));
    printf("catch at k= %d\n", k);
  end_try_catch
  drawnow();
endfor

I see that stem has type=hggroup with 2 children, while plot has type=line.
So I figured that the problem arises because the command set(hs,'xdata'...)
is actually fixing one child at time. Is that right?

Anyway I have to say that it would be more convenient if a single set()
command took care of these details automatically. Don't you think?






--
View this message in context: 
http://octave.1599824.n4.nabble.com/changing-xdata-in-stem-plot-tp4654057.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

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