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;
0 个评论
采纳的回答
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".
2 个评论
dpb
2022-9-15
Thanks for feedback; glad to help...
If this resolved the issue, please go ahead Accept the Answer -- let's other know if no other reason...
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!