フィルターのクリア

How can I define the colors of the bar, depending on their Z value?

14 ビュー (過去 30 日間)
Ana Bianco
Ana Bianco 2019 年 9 月 23 日
コメント済み: Adam Danz 2019 年 9 月 24 日
Hello all,
I have this matrix (8x8) with z values between 0 and 1.
For each 0.1, I want the bar to be varying from the lightest to the darkest color.
Hor can I do this?
I did a bar3 for the matrix.
Thanks in advance :)
  3 件のコメント
Adam
Adam 2019 年 9 月 23 日
Do you want literally the same colourmap repeated 10 times or are you expecting it to also get darker as you move up from 0 to 1? If the former then just create your colourmap and use e.g.
myNewcolourmap = repmat( myColourmap, [10, 1] );
to create one that varies within each 10th of the range. Of course if you want to start compressing the colour range to less than 0-1 or use it on arbitrary ranges it may not do what you want, but for a fixed 0-1 range it should work fine.
Ana Bianco
Ana Bianco 2019 年 9 月 23 日
For example, with this comand :
b = bar3(FINALVALUESMAC);
for k = 1:length (b)
zdata = b(k).ZData;
b(k).CData = zdata;
b(k).FaceColor = 'interp';
end
I got this figure: snapshot1.png
but I want the color range to be specified by me.

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

採用された回答

Adam Danz
Adam Danz 2019 年 9 月 23 日
編集済み: Adam Danz 2019 年 9 月 23 日
After the section of code in your comment above, you can change the colormap to one of Matlab's built-in colormaps or you can create your own. Then use caxis() to scale the color range if needed.
colormap('hot')
% or can flip the colormap
colormap(flipud(colormap('hot')))
% If needed, scale color range
caxis([0,1]) % or whatever range you want
  2 件のコメント
Adam Danz
Adam Danz 2019 年 9 月 24 日
Ana Bianco's answer moved here as a comment
Perfect! That worked! Thank you!
Adam Danz
Adam Danz 2019 年 9 月 24 日
Glad I could help!

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by