How to fix the values of different histograms 2D to have the same color reference?

조회 수: 1 (최근 30일)
Hi, I'm trynig to plot several histograms and I'll like to see the difference between them. For that, Matlab fixes the colors based on the maximum value for each histogram, so despite of having different values (amplitude) between histograms the color of the highest and the lowest are the same. That makes it difficult to have an idea of the real difference between them, and makes it necessary to check the colorbar. In the images, I would like to have more intense colors for the first histogram and less intense for the second one, since the values are higher in the first one. How could I fix this?
Here is the code I'm using for the histograms:
string1 = 'HL vs MML at';
string2 = num2str(currentFreq);
ti = strcat (string1,{' '},string2,{' '},'Hz');
Xedges = [0 0:10:100 100];
Yedges = [0 0:10:100 100];
h = histogram2(A, B,Xedges,Yedges,'DisplayStyle','tile','ShowEmptyBins','on');
hcb=colorbar;
colorTitleHandle = get(hcb,'Title');
titleString = 'Number of ears';
set(colorTitleHandle ,'String',titleString);
ylabel('MML (dB)')
xlabel('Hearing Loss (dB HL)')
ask.png
Thanks a lot in advance

답변 (2개)

Image Analyst
Image Analyst 2019년 1월 11일
You can specify caxis() for each plot to be the same.
% First do one image.
% then call caxis():
caxis([0, 33]);
% Now make second image in second axes.
% And apply the same caxis limits.
caxis([0, 33]);

Shubham Gupta
Shubham Gupta 2019년 1월 11일
편집: Shubham Gupta 2019년 1월 11일
One way to do this is to use "colormapeditor". Type the following in command window :
colormapeditor
In the dialog box, you can change the limits of the Colorbar to be equal for both plots.
Note : Setting colormap limits to be the maximum of the two plots should work much better
  댓글 수: 2
Image Analyst
Image Analyst 2019년 1월 11일
"Note : Setting colormap limits to be the maximum of the two plots should work much better"
To do this, you use caxis() like I showed in my Answer.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Blue에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by