How can a draw a line between two points?
42 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Sandy
am 3 Apr. 2014
Kommentiert: Sandy
am 9 Apr. 2014
I have a plot that looks like the one below. I want to make vertical lines that connect each individual pair of blue & red points. How can I do this?
PARTIAL CODE:
plot(x, average,'o', 'MarkerEdgeColor', 'b', 'MarkerFaceColor', 'b'); % Blue points
hold on
plot(x, average_2,'o', 'MarkerEdgeColor', 'r', 'MarkerFaceColor', 'r'); % Red points
0 Kommentare
Akzeptierte Antwort
Kelly Kearney
am 3 Apr. 2014
Assuming that x, average, and average_2 are all row vectors
axes;
hold on;
plot(x, average,'o', 'MarkerEdgeColor', 'b', 'MarkerFaceColor', 'b'); % Blue points
plot(x, average_2,'o', 'MarkerEdgeColor', 'r', 'MarkerFaceColor', 'r'); % Red points
plot([x;x], [average; average_2], '-k');
If the data are column vectors you'll have to transpose the arrays.
Weitere Antworten (1)
Azzi Abdelmalek
am 3 Apr. 2014
Bearbeitet: Azzi Abdelmalek
am 3 Apr. 2014
plot(x, average,'-o', 'MarkerEdgeColor', 'b', 'MarkerFaceColor', 'b');
hold on
plot(x, average_2,'-o', 'MarkerEdgeColor', 'r', 'MarkerFaceColor', 'r');
hold off
0 Kommentare
Siehe auch
Kategorien
Mehr zu Scatter 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!