How to plot a map with logarithmic colorbar and colormap with imagesc
25 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Francesca Pisani
il 27 Ott 2023
Commentato: Walter Roberson
il 30 Ott 2023
Hello, I ask for your help since I've been trying to create maps with a logarithmic colormap and colorbar, but I haven't managed so far.
The problem is I have a loop through which I plot a number of maps using "imagescn", each map is referred to an hour of the day and represents the deposited kilograms of sediments into a lake due to a turbid input. Since the input changes a lot during the day, I want to be able to see in each plot values that range between 0 and 62 (maximum value of all times). As I'm doing now, nothing has changed and the colorbar and colormap are still linear, so that I can't see very well the smallest values . Also, I want the every plot in my loop has the same colorbar limits.
This is a part of my code: (i'm using MatlabR2021a)
for t = 10:10:200 %every t is referred to a time of the day
figure(t)
colormap('parula');
my_clim=[0 62];
c=[0 0.001 0.01 0.02 0.05 0.1 0.2 0.3 0.4 0.5 0.6 0.8 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 45 50 55 60];
data=array_data_rotated_t; %this array changes at each timestep and it is a 27x29 double array
contourf(log(data(:,:)),log(c));
colormap(parula);
caxis(log([c(1) c(length(c))]));
colorbar('FontSize',11,'YTick',log(c),'YTickLabel',c);
imagescn(array_data_rotated_t);
h=colorbar;
end
Thank you for your help!
Francesca
3 Commenti
Walter Roberson
il 27 Ott 2023
imagescn appears to be https://www.mathworks.com/matlabcentral/fileexchange/61293-imagescn
Risposta accettata
Sulaymon Eshkabilov
il 29 Ott 2023
for t = 10:10:200 %every t is referred to a time of the day
figure(t)
colormap('parula');
my_clim=[0 62];
c=[0 0.001 0.01 0.02 0.05 0.1 0.2 0.3 0.4 0.5 0.6 0.8 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 45 50 55 60];
data=array_data_rotated_t; %this array changes at each timestep and it is a 27x29 double array
contourf(log(data(:,:)),log(c));
colormap(parula);
caxis(log([c(1) c(length(c))]));
colorbar('FontSize',11,'YTick',log(c),'YTickLabel',c);
imagescn(array_data_rotated_t);
h=colorbar;
set(gca,'ColorScale','log') % USE this command
end
4 Commenti
Walter Roberson
il 30 Ott 2023
When you subplot(A, B, C) then C must not exceed A*B. subplot(3,1,t) then t must be 1 2 or 3 (or a vector of multiple values in that range)
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Colormaps in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!