Put to white the plot space outside a geometric shape

Dear all
I am using the attached colorbar to generate some plots, which looks like this:
As you can see, because the colorbar seems to not assign a plain white color to zeros, the background color outside the geometric shape has some residual color. How could I avoid this problem efficiently?

 採用された回答

Mathieu NOE
Mathieu NOE 2024 年 8 月 29 日
編集済み: Mathieu NOE 2024 年 8 月 29 日

1 投票

hello
have you checked that the colorbar is symetric around zero (to have white color correspind to zero exactly ? )
this requires to use caxis as in example below (the seond plot is "whiter" than the first one).
RdBu250cbrewer = readmatrix('RdBu_250_cbrewer2.txt');
Z = peaks(100) + 1 ;
% without caxis
figure(1),
imagesc(Z)
colormap(RdBu250cbrewer);
colorbar('vert')
% with caxis
figure(2),
zm = max(abs(Z),[],'all');
imagesc(Z)
colormap(RdBu250cbrewer);
caxis([-zm zm]) % force colors to be used symmetricaly so white correspond to zero
colorbar('vert')

3 件のコメント

Mathieu NOE
Mathieu NOE 2024 年 8 月 29 日
also plain white is rgb = [ 1 1 1] , which does not appear in your color map, as the closest values are like
0.966924490903 0.968909725660 0.970034318301
so it's a bit grey (very very slightly)
Mathieu NOE
Mathieu NOE 2024 年 8 月 29 日
there are lot's a colormap generators on Fex, for my fun I used this one :
her's the result obtained (code below)
% with redwhiteblue
% (Fex : https://fr.mathworks.com/matlabcentral/fileexchange/86932-red-white-blue-colormap)
figure(3)
imagesc(Z)
zmin = min(Z,[],'all');
zmax = max(Z,[],'all');
colormap(redwhiteblue(zmin, zmax));
colorbar;
DGM
DGM 2024 年 8 月 29 日
I'll add that the RdBu map never reaches white in the center. It maxes out at [0.9686 0.9686 0.9686]. Since the given map is even length, it never actually includes this neutral color.

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

その他の回答 (0 件)

カテゴリ

質問済み:

2024 年 8 月 29 日

コメント済み:

DGM
2024 年 8 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by