How can I make the MarkerIndices automatic?
11 次查看(过去 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 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!