How to set different marker and marker edgecolor on single line in Plot?

117 次查看(过去 30 天)
Hello sir!
I want to set different marker and marker edgecolor on single line in Plot? Please, how can i do that, Thanks a lot!
Here example variable x, y. When under the value 12 (red line in photo), i want to set different marker and color for that two points.
x = 1:11;
y = [30 27 31 28 9 34 33 35 33 33 10];
y1 = 12;
p = plot(x,y,'-k', 'Marker', '*', 'MarkerEdgeColor','g');
hold on;
plot(x,y1*ones(size(x)),'LineStyle','--');
hold off;

采纳的回答

dpb
dpb 2022-9-14
plot is a single object for each line -- ergo, each line can have only one linestyle (colors, marker, line). To have a second marker/color/etc. means another line...
x = 1:11;
y = [30 27 31 28 9 34 33 35 33 33 10];
y1 = 12;
hL=plot(x,y,'-k', 'Marker', '*', 'MarkerEdgeColor','g');
hold on;
yline(y1,'LineStyle','r--')
ix=(y<y1); % the offending locations
hL(2)=plot(x(ix),y(ix),'xr'); % put red 'X' there...
Can set any/all of the marker properties as desired -- "salt to suit".

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by