imagesc make all negatives values black
3 ビュー (過去 30 日間)
古いコメントを表示
I have the following code which is part of a subplot series. I want to change it so that all negative values become a certain colour (preferably black). I am stuck as to how to achieve this.
figure(3)
subplot(3,3,1)
imagesc(coeffA40)
title ('A40 Coefficients')
caxis([minCoeff, maxCoeff])
myColorMap = hsv(256);
myColorMap(1,:) = 1;
colormap(myColorMap);
grid on
ax = gca
ax.LineWidth = .75
ax.GridColor = 'k'
ax.GridAlpha = .2
ax.XTick = [10 20 30 40];
ax.YTick = [10 20 30];
ax.XTickLabel = {'', '', '', ''};
ax.YTickLabel = {'','',''};
ax.TickLength =[0.0 0.0]
ax.XTickLabelRotation = 45
Thank you in advance for any help!
0 件のコメント
回答 (1 件)
Image Analyst
2016 年 3 月 29 日
Several ways. One is to create a temporary image
displayedImage = coeffA40; % Initialize
displayedImage(displayedImage <=0) = 0;
cmap = jet(256);
cmap(1,:) = 0; % Lowest gray level appears black.
imshow(displayedImage);
colormap(cmap);
colorbar;
Another might be to alter the colormap so that it applies between 0 and the max.
cmap = jet(256);
cmap(1,:) = 0; % Lowest gray level appears black.
imshow(coeffA40);
colormap(cmap);
colorbar;
caxis([0, max(coeffA40(:))]);
(Both of these are untested - just off the top of my head.)
3 件のコメント
Image Analyst
2016 年 3 月 29 日
Set the nans to the max value (or the white value) before display, something like:
displayedImage(isnan(displayedImage)) = max(displayedImage(:));
Walter Roberson
2016 年 3 月 29 日
image(coeffA40, 'AlphaData', double(~isnan(coeffA40)) )
参考
カテゴリ
Help Center および File Exchange で Orange についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!