draw multiple line segments, stairs(), plot() function?
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Chen Chen
am 14 Okt. 2015
Kommentiert: Ian Hunter
am 16 Jul. 2019
assuming coordinates are known. x = [1,10], y = [1,10] Please help. Note: should be exactly the same as in the picture. (with dashes, circle points)
Thanks
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 14 Okt. 2015
You can draw all of the solid or dashed segments at once by providing appropriate coordinates. Place NaN between the pairs:
x = [x1 x1 NaN x2 x2 NaN x3 x3];
y = [y1 y2 NaN y2 y3 NaN y3 y4];
plot(x, y, '-'); %no marker!
hold on
x = [0 x1 Nan x1 x2 Nan x2 x3];
y = [y1 y1 NaN y2 y2 Nan y3 y3];
plot(x, y, '--'); %no marker
and then draw all of the markers of each type
x = [0 x1 x2 x3];
y = [y1 y2 y3 y4];
plot(x, y, 'o'); %no line
x = [x1 x2 x3];
y = [y1 y2 y3];
plot(x, y, 'o', 'MakerFaceColor', 'k'); %no line, fill the marker
To create the axes as lines with arrows, create annotation arrows; see http://www.mathworks.com/help/matlab/ref/annotationarrow-properties.html
1 Kommentar
Ian Hunter
am 16 Jul. 2019
Very helpful. A few mistyped NaNs but otherwise solved my problem completely.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Line Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!