MATLAB: Display Marker for current Point in animated line

animatedlineplot

Hello,
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;
h.LineStyle='-';
h.Color='blue';
x = mmatrix(:,2);
y = mmatrix(:,1);
for k = 1:length(x)
addpoints(h,x(k),y(k));
drawnow
end
I tried to add a second addpoint but markers are all printed.
Regards

Best Answer

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.
ADDENDUM
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
hAL.LineStyle='-';
hAL.Color='blue';
% 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)
addpoints(hAL,x(k),y(k));
set(hS,'xdata',x(k),'ydata',y(k)) % update the marker position
drawnow
end
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?