Display Marker for current Point in animated line

22 ビュー (過去 30 日間)
Jan w
Jan w 2016 年 12 月 29 日
コメント済み: Ankit Sahay 2019 年 5 月 19 日
I'm plotting hysteresis loops by a dataset with animatedline. How can I make the current plotted datapoint visible, with a Marker for example? I'm thinking of these:
My code:
h = animatedline;
x = mmatrix(:,2);
y = mmatrix(:,1);
for k = 1:length(x)
I tried to add a second addpoint but markers are all printed.
  1 件のコメント
Ankit Sahay
Ankit Sahay 2019 年 5 月 19 日
What is "mmatrix" for?



dpb 2016 年 12 月 30 日
編集済み: dpb 2016 年 12 月 30 日
linestyle and other properties are global to a line; to have a different style/marker/color/whatever apply to only a single point will require that point be independent of the line. A scatter object would work for it; draw the line irrespective but w/o the marker then update the [X|Y]Data property for the scatter object to show the one point.
To do this all with HG2, you'd have to create a second animatedline with the desired marker style, color, etc., and then addpoints to its handle each iteration after you clearpoints the previous point of that handle; that appears to me likely to be more overhead intensive than the scatter solution suggested that just updates a single data array point albeit it mixes old and new styles...
Unfortunately, I am at R2012b which predates all this stuff so can't actually test here but there's not a method documented with animatedline to just modify a data point as you're needing to do here...
To illustrate, my solution would be sotoo--
hAL = animatedline; % line handle
% defaults for the marker
hAx=gca; % get the axis handle
sz=10; % size of marker
clr='b'; % color
hS=scatter(hAx,nan,nan,sz,clr); % initial point won't show but creates handle
x = mmatrix(:,2);
y = mmatrix(:,1);
for k = 1:length(x)
set(hS,'xdata',x(k),'ydata',y(k)) % update the marker position
See the doc's for scatter for other options, details...
Seems like this ability would be a reasonable enhancement request to the animated line going forward...why not submit this query to TMW as such?
  3 件のコメント
Jan w
Jan w 2016 年 12 月 31 日
your guess is right. I solved the pace problem:
drawnow limitrate
simple trick! Thanks


その他の回答 (0 件)


Help Center および File ExchangeDiscrete Data Plots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by