Is there any way to plot values that are exponent multiples of 10 as colorbar directly without having to take their log
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Mathan
el 7 de Abr. de 2022
I was trying to plot 3 variables (depth, height, particles - these are attached as .mat files) with depth along the x axis, height along the y axis and particles as colors, using pcolor. This is the code which I used to obtain the plots (I used log10 for particles since their values were multiples of 1e10) and obtained the figure attached as log.jpg
d = load('depth.mat');
h = load('height.mat');
p = load('particles.mat');
depth = d.depth;
height = h.height;
particles = p.particles;
pcolor(depth, height, log10(particles))
bar = colorbar('XTickLabel', {'10^{5}', '10^{6}', '10^{7}'}, 'XTick',linspace(log10(1e5), log10(1e7),3));
caxis([log10(1e5) log10(1e7)])
But I really wanted to plot (depth, height, particles) and so I tried the following code:
d = load('depth.mat');
h = load('height.mat');
p = load('particles.mat');
depth = d.depth;
height = h.height;
particles = p.particles;
pcolor(depth, height, particles)
bar = colorbar('XTickLabel', {'10^{5}', '10^{6}', '10^{7}'}, 'XTick',linspace(1e5, 1e7, 3));
caxis([1e5 1e7])
This however gave me a different plot (attached as without_log.jpg). I am not sure why that occured since even if we take the log of the values and plot them, the so obtained values should still fall between the same color limits (for example, if the particle value of (say) 1e7*2.1232 corresponded to light red then log10(1e7*2.1232) should also correspond to light red since the color axis was also properly adjusted for both cases as shown in my code). Instead of getting the same plots, I am wondering why I have obtained the same plots.
Any feedback would be highly appreciated.
Thank you.
0 comentarios
Respuesta aceptada
David Goodmanson
el 7 de Abr. de 2022
Hi Mathan,
The colorbars cover the same range in each case, but It's still apples and oranges. Consider the value 1e6 In log space, it's halfway between 1e5 and 1e7, so the color will be halfway up the colorbar on the using_log figure. But in linear space, 1e6 is (approximately) 10% of the way from 1e5 to 1e7, so you will only be 10% up on the colorbar on the without_log figure. So on the parts of the figure that aren't yellow, the without_log figure is darker.
6 comentarios
David Goodmanson
el 9 de Abr. de 2022
Hi Mathan,
the colorbar looks pretty good to me. The only thing I can really find fault with is that the lower end is not marked .1, so it's hard to tell if the minimum value is 1e-5 or 0. On that note, it's probably better in linear scale to go from 0 to 1e7 rather than 1e5 to 1e7. And yes, the enitire range from 1e5 to 1e6 is squished into the narrow blue part of the colorbar, because that's what linear scale does.
Más respuestas (0)
Ver también
Categorías
Más información sobre Colorbar en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!