フィルターのクリア

how to add a corresponding colorbar with a plot lines

3 ビュー (過去 30 日間)
TESFALEM ALDADA
TESFALEM ALDADA 2021 年 11 月 6 日
コメント済み: TESFALEM ALDADA 2021 年 11 月 8 日
Hello guys,
I created a plot with the color bar. But i couldnot make sure that the color scales on the plot are matching with the colorbar.
For the code below the respective image is shown. And i wanted to assign a value of 1 to dark gray and 0 to light gray in the colorbar.
I will appreciate your kind response.
%%
y=1+rand(10,10)*9;
col = ones(10,3).*rand(10,1);
col = sort(col,'ascend');
colormap(gray(10))
for i=1:10
plot([1 10],[1 10]); hold on
plot(y(:,i),'LineWidth',1,'color',col(i,:));
hc = colorbar;
cb=[0:0.1:1]';
set(hc, 'YTick',cb,'YTickLabel',cb,'TicksMode','auto')
end

採用された回答

DGM
DGM 2021 年 11 月 7 日
Just flip the colormap.
y=1+rand(10,10)*9;
col = ones(10,3).*rand(10,1);
col = sort(col,'ascend');
plot([1 10],[1 10]); hold on
for i=1:10
plot(y(:,i),'LineWidth',1,'color',col(i,:));
end
hc = colorbar;
colormap(flipud(gray(10)))
  1 件のコメント
TESFALEM ALDADA
TESFALEM ALDADA 2021 年 11 月 8 日
Okay got it. A lot of thank!

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

その他の回答 (0 件)

カテゴリ

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