How can a draw a line between two points?
42 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Kelly Kearney
le 3 Avr 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.
Plus de réponses (1)
Azzi Abdelmalek
le 3 Avr 2014
Modifié(e) : Azzi Abdelmalek
le 3 Avr 2014
plot(x, average,'-o', 'MarkerEdgeColor', 'b', 'MarkerFaceColor', 'b');
hold on
plot(x, average_2,'-o', 'MarkerEdgeColor', 'r', 'MarkerFaceColor', 'r');
hold off
0 commentaires
Voir également
Catégories
En savoir plus sur Scatter Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!