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

2 visualizaciones (últimos 30 días)
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

Respuestas (2)

Image Analyst
Image Analyst el 11 de En. de 2019
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 el 11 de En. de 2019
Editada: Shubham Gupta el 11 de En. de 2019
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 comentarios
Image Analyst
Image Analyst el 11 de En. de 2019
"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.

Iniciar sesión para comentar.

Categorías

Más información sobre Blue en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by