How to plot single colorful line?

2 vues (au cours des 30 derniers jours)
Zack Trahem
Zack Trahem le 20 Juin 2023
Commenté : Zack Trahem le 20 Juin 2023
Iam trying to plot a single line graph varaying colororder depending on the intensity increse.
x=[1 2 3 4 5 6 ];
y=[1 2 3 4 5 6 ];
plot(x,y), colororder(jet)
expecting to color change over line. Thank you.

Réponse acceptée

KSSV
KSSV le 20 Juin 2023
x=[1 2 3 4 5 6 ];
y=[1 2 3 4 5 6 ];
z = zeros(size(x));
col = x; % This is the color, vary with x in this case.
surface([x;x],[y;y],[z;z],[col;col],...
'facecol','no',...
'edgecol','interp',...
'linew',2);
  1 commentaire
Zack Trahem
Zack Trahem le 20 Juin 2023
Thank you so much, this is what i was looking for.

Connectez-vous pour commenter.

Plus de réponses (1)

DGM
DGM le 20 Juin 2023
Modifié(e) : DGM le 20 Juin 2023
This can't be done with a single line object. It can be done with multiple line objects or with patch objects. This thread has examples of both.

Catégories

En savoir plus sur Color and Styling 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!

Translated by