How can I make the MarkerIndices automatic?
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have an issue with using the MarkerIndices property on a line. I want to selectively highlight a few points by changing the MarkerIndices value, then later restore the markers to all the points. If I add additional points to the line though, they don't have markers, since the MarkerIndices have been manually set. Is there a way to restore the MarkerIndices state to 'automatic' once it's been set manually?
This snippet demonstrates my issue. Create a line, highlight a point, restore the markers to all the points, then add more data to the line. Only the first 10 points end up with markers.
figure
H=plot(rand(1,10),rand(1,10),'ko-');
H.MarkerIndices=5;
drawnow
H.MarkerIndices=1:length(H.YData);
H.XData=[H.XData,rand(1,10)];
H.YData=[H.YData,rand(1,10)];
0 Kommentare
Antworten (1)
Steven Lord
am 22 Mai 2020
h = plot(1:10, 1:10, 'o-');
% Eliminate half the markers
h.MarkerIndices = 1:2:10;
% Change the number of points. No new markers appear.
v = 1:20;
set(h, 'XData', v, 'YData', v)
% Restore all the markers, old and new
h.MarkerIndices = 1:numel(h.XData);
Siehe auch
Kategorien
Mehr zu Line Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!