colorbar for line plot number

2 ビュー (過去 30 日間)
Frank Hofmann
Frank Hofmann 2022 年 4 月 8 日
回答済み: Star Strider 2022 年 4 月 8 日
I want to use a colorbar as indicator for the number of a series of line plots.
Actual limits of the colorbar: 0 to 1
Intended limits for the colorbar: Limits from 1 to 10
Example code:
Nc = 10;
x=[0 2];
figure();
colororder(parula(Nc));
for i=1:Nc
if i==1
hold on;
end
plot(x, i*x);
end
colorbar;

採用された回答

Star Strider
Star Strider 2022 年 4 月 8 日
The colorbar apparently does not want to do this by itself, since it appears to scale to the ‘z’ values in a 3D plot (or equivalent, such as contour).
The only way to have it do what you want in this instance is to tell it —
Nc = 10;
x=[0 2];
figure();
colororder(parula(Nc));
i=1:Nc;
plot(x, i(:)*x);
hcb = colorbar;
tix = hcb.Ticks;
hcb.TickLabels = compose('%2.0f',tix*Nc);
.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeColor and Styling についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by