How to make line plot of 3 different colors?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello everyone,
Is there a way to change colors of line plot different at specific intervals? For example, I want line from 18-0 to be of one color, from 0-(-10) represents different color and -10 till -35 to be of an other color. Thank you.
0 commentaires
Réponse acceptée
Chunru
le 25 Juil 2021
% data
x = [2:26 26:-1:-5];
y = [20:-1:-4 -5:-1:-36];
idx1 = y>=0;
idx2 = y>=-10 & y<=0;
idx3 = y<=-10;
plot(x(idx1), y(idx1), 'r-', x(idx2), y(idx2), 'g-', x(idx3), y(idx3), 'b-');
set(gca, 'YDir', 'reverse')
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Instrument Connection and Communication 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!