Filter löschen
Filter löschen

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

83 Ansichten (letzte 30 Tage)
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;

Akzeptierte Antwort

dpb
dpb am 14 Sep. 2022
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 Kommentare
dpb
dpb am 15 Sep. 2022
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...

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by