How can I adjust the settings so that the following heatmap retains most of the details?

55 vues (au cours des 30 derniers jours)
ma Jack
ma Jack le 7 Déc 2024 à 2:23
Modifié(e) : ma Jack il y a environ 13 heures
How can we make the smaller values in a matrix more visible on a heatmap, without removing the large values, when the colorbar set to a logarithmic scale doesn't work?
  1 commentaire
ma Jack
ma Jack le 7 Déc 2024 à 9:36
Apologies for the unclear phrasing of my previous question. Here is the updated version.
As shown in the figure below, there are two heatmaps, both created using the same matrix . I really like the color scheme used in the colorbar, so I hope to keep it unchanged. The only difference between the two plots is the setting of clim, but now I want to set clim([0,1]) while still displaying detailed information similar to the clim([0,0.2]) case. How can I achieve this? I would appreciate any suggestions.

Connectez-vous pour commenter.

Réponses (2)

Image Analyst
Image Analyst le 7 Déc 2024 à 5:00
Please change the subject line of your post because it's not informative.
You can set the heatmap to whatever you want. If log doesn't work then change the colormap.
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
  2 commentaires
ma Jack
ma Jack le 7 Déc 2024 à 7:11
Thank you very much for your suggestion. I have now updated my question.
Image Analyst
Image Analyst le 8 Déc 2024 à 16:05
I doubt that and I doubt that you read the tutorial link I gave you. For example your subject line still says "Hi, everyone!" Do you really think that is a descriptive subject line regarding mainipulating the colormap? Also, I don't see any data attached with the paperclip icon so no one can try anything with your actual data. No one can write code based on just a screenshot. We need actual data. Please attach your data in a .mat file
save('answers.mat', 'yourDataVariable'); % Use the actual name of your variable inside single quotes.
I'm imagining that you have some very non uniform data with tons of values with high values, and a very few values with low values. Just give it to us. Don't force us to create our own data or most likely, no one will.

Connectez-vous pour commenter.


Star Strider
Star Strider le 7 Déc 2024 à 12:04
Modifié(e) : Star Strider le 8 Déc 2024 à 15:36
The clim approach could of course work. Another option that might work is to use the logarithms of the ‘z’ values. (The values must all be greater than zero for that to work, however you could accomplish tthat by simply adding the minimum value of all the ‘z’ values — plus a small offset. — to the entire matrix.)
Example —
t = linspace(0, 1);
s = (sin(2*pi*t)+1) .* t*2;
sm = s(:) * s;
figure
imagesc(sm)
colormap(turbo)
colorbar
title('Linear z')
figure
surf(sm)
colormap(turbo)
colorbar
title('Surface Representation')
figure
imagesc(log(sm+min(sm(:))+1))
colormap(turbo)
hcb1 = colorbar;
hcb1.TickLabels = compose('%.2f',exp(hcb1.Ticks)-1);
title('Logarithmic z')
figure
surf(log(sm+min(sm(:))+1))
colormap(turbo)
hcb2 = colorbar;
hcb2.TickLabels = compose('%.2f',exp(hcb1.Ticks)-1);
title('Surface Representation')
EDIT — (8 Dec 2024 at 15:36)
Tweaked ‘Logarithmic z’ colorbar ticks.
.

Catégories

En savoir plus sur Data Distribution Plots dans Help Center et File Exchange

Produits


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by