# MATLAB How to use a suitable color bar?

Tags:
1. Mar 9, 2016

### kelvin490

I have a picture which shows the magnitude of some value in terms of color, like this one:

https://www.dropbox.com/s/yoh0n9cqftvrtlz/bar.jpg?dl=0

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?

2. Mar 9, 2016

### Staff: Mentor

I don't know of a way to ask Matlab to use a non-linear color scale, but you can remedy the problem by plotting, for instance, the log of your data instead of the raw data itself.

3. Mar 9, 2016

### kelvin490

Readers are usually more comfortable with un-scaled data. Many other posts only offers solutions which requires scaling the data, but rescaling the colorbar without altering the data is more preferable. Thanks though.

4. Mar 9, 2016

### Staff: Mentor

One possibility is of course to use other software. I, for instance, use Igor Pro for plotting, and it does log color scaling.

The third message, dated 20 Jul, 2007 17:12:42, has a workaround.

Last edited by a moderator: May 7, 2017
5. Apr 2, 2016

### kreil

It looks like the figure is washed out at the bottom (blue), so you'll want to use a smaller max value. You'll want to play with the colorbar limits to find where the "interesting" range is, i.e. where the bottom values clipping to dark blue and the top values clipping to bright red are somewhat equalized.

You can change the colorbar limits this way (this example goes to 0.15 instead of 0.35, about half the range):

Code (Text):

% Get a handle to the current figure object
ax = gca;

% Adjust the CLim property to use a different range of values for the colorbar.
% Scaled by 1e4 since it seems you use this scaling in your plot.
ax.CLim = 1e4*[0, 0.15];