Reputation: 351
I have a picture which shows the magnitude of some value in terms of color, like this one:
The higher the magnitude, the more it looks red. However there are only a few points at the edge has very high values and most of the points have much lower values. If a colorbar with equal intervals is used the picture just looks blue throughout and the values in most areas cannot be distinguished.
Is it possible to set a colorbar that has, say, exponentially increasing intervals (or others) so that the center part can also show different colors?
Upvotes: 2
Views: 333
Reputation: 45741
Here is one way, it's not quite right but it's close. The idea is to make your own log spaced colour map. I do it by using linear interpolation between log spaced break points. It could probably be improved to use logarithmic interpolation (and maybe have better end cases):
First I simulate some data (open to suggestions for simulating data that better illustrates this example):
M = exp(rand(50)*10)
Then plot it (ignore the figure(2)
, that's just to make this match the image later)
n = 64
figure(2)
imagesc(M)
colormap(jet(n))
colorbar
now create a log spaced colour map
linMap = jet(n);
breaks = round(0:n/5:n)';
breaks(1) = 1;
cBreaks = linMap(breaks,:);
idx = 2.^(6:-1:1)';
idx(end) = 0; %// this part is hacky
logMap = interp1(((idx)/64)*max(M(:)),flipud(cBreaks),linspace(0,max(M(:)),64)); %// based on http://stackoverflow.com/questions/17230837/how-to-create-a-custom-colormap-programatically
figure(1)
imagesc(M)
colormap(logMap)
colorbar
results in
as you can see, the data remain unchanged and the data inspector still gives you back the same values but the colour bar is pretty much on a log scale now. I'd be interested to see what this looks like on your data.
Upvotes: 3