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

123 ビュー (過去 30 日間)
Alex Zai
Alex Zai 2022 年 9 月 14 日
コメント済み: dpb 2022 年 9 月 15 日
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".
  2 件のコメント
Alex Zai
Alex Zai 2022 年 9 月 14 日
Thanks a lot! It's work :).
dpb
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 ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by