How can I make the MarkerIndices automatic?
12 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Steven Lord
2020 年 5 月 22 日
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);
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!