问题
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