フィルターのクリア

How to plot single colorful line?

2 ビュー (過去 30 日間)
Zack Trahem
Zack Trahem 2023 年 6 月 20 日
コメント済み: Zack Trahem 2023 年 6 月 20 日
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.

採用された回答

KSSV
KSSV 2023 年 6 月 20 日
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 件のコメント
Zack Trahem
Zack Trahem 2023 年 6 月 20 日
Thank you so much, this is what i was looking for.

サインインしてコメントする。

その他の回答 (1 件)

DGM
DGM 2023 年 6 月 20 日
編集済み: DGM 2023 年 6 月 20 日
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.

カテゴリ

Help Center および File ExchangeColormaps についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by