imagesc make all zeros white?

60 ビュー (過去 30 日間)
Robert
Robert 2015 年 9 月 25 日
コメント済み: I.H 2021 年 6 月 2 日
I have the following code. The output is a matrix and I want all of the zeros to be displayed as white. How can I do this?
figure (1)
imagesc(testNSE);
title ('Model vs Observations All NSE')
caxis ([0,1])
colormap(jet)
colorbar
Thank you in advance for any help

採用された回答

Image Analyst
Image Analyst 2015 年 9 月 25 日
編集済み: Image Analyst 2015 年 9 月 25 日
Set the first row of the colormap, which will represent 0 since you set up caxis to go from 0 to 1, to be [1,1,1];
myColorMap = jet(256);
myColorMap(1,:) = 1;
colormap(myColorMap);
colorbar
  13 件のコメント
Image Analyst
Image Analyst 2021 年 6 月 1 日
@I.H, if you set a different top and bottom value with caxis(), you'll have to find out where the 0 value lies. So if you have the top value be 1000, and the bottom value be -200, then you can find out where zero is by fitting a line and evaluating it at zero.
coefficients = polyfit([-200, 1000], [1, 256], 1);
% y = coefficients(2) * x + coefficients(1)
zeroIndexRow = round(coefficients(1)); % Evaluate at x = 0 to get the row of the colormap
my_color_map(zeroIndexRow, :) = 1; % Set this row to all 1's to get white.
I.H
I.H 2021 年 6 月 2 日
Okay, thank you very much

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by