force colour of pixels with certain values to black when using a colormap with imagesc
40 ビュー (過去 30 日間)
古いコメントを表示
Hi there,
I'm using imagesc to produce the following image (which is a plot of angular error for a given azimuth and elevation value):
Using caxis([0,10]); to constrain the range of valid values between 0 and 10 degrees is great. BUT, what I want to be able to do is assign another custom colour (e.g., white or black) to all values > 10. Can someone help me do this when plotting with imagesc?
I've tried defining a custom colourmap by setting the uppomost value to white for example, BUT, it sets all values that are 10 also to white (see below image). I need to retain those values...
So I'm looking for a way of forcing the colormap and colorbar to remain as above but only for values > 10 (the last image actually sets results = 10 also to white but I only want this for values greater than the maximum value of my colorbar), Like a thresholding operation.
Any assistance would be greatly received!
Many thanks.
Mark
0 件のコメント
採用された回答
DGM
2022 年 10 月 31 日
編集済み: DGM
2022 年 10 月 31 日
If you're using imagesc(), image(), or imshow(), you can use the 'alphadata' property:
% we have some data that spans from 0 beyond 10
Z = peaks(100);
Z = normalize(Z,'range')*15;
% create a mask to describe regions within normal data range
alpha = Z<=10;
imagesc(Z,'alphadata',alpha)
colorbar
You can then choose the background color by setting the 'color' property of the parent axes:
set(gca,'color',[1 0.3 0.7]) % or any color you want
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Orange についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!