MATLAB plot's MarkerIndices property

微笑、不失礼 提交于 2021-02-09 10:54:01

问题


How can I use MarkerIndices with plot?

x = linspace(-10,10,101);
y = sin(x);

plot(x, y,  'color', 'blue', ...
            'LineStyle','-', ...
            'Marker', 's', ...           
            'MarkerIndices', [1, 5, 10], ...        
            'MarkerEdgeColor', 'black',...
            'MarkerFaceColor','yellow');

Error message

Error using plot
There is no MarkerIndices property on the Line class.

Error in plotting3 (line 4)
plot(x, y,  'color', 'blue', ...

回答1:


MarkerIndices became available in R2016b version.

The workaround is plotting two times:

MarkerIndices = [1, 5, 10];
myplot = plot(x, y, 'b-.');
hold on;                 
mymarkers = plot(x(MarkerIndices), y(MarkerIndices), 'ro');    
legend(myplot)

This should work. I commented that this is in reference to a post on MathWorks Community. Will provide a link if found it.

P.S. This is the LINK to the answer;



来源:https://stackoverflow.com/questions/44076215/matlab-plots-markerindices-property

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!