MATLAB How to use a suitable color bar?

Click For Summary
The discussion focuses on the challenge of visualizing data with a color scale in MATLAB, particularly when most values are low, leading to a predominance of blue in the color representation. The original poster seeks a solution for implementing a non-linear color scale, such as exponentially increasing intervals, to better distinguish values in the center range without altering the raw data. A suggested workaround involves plotting the logarithm of the data, although this changes the data representation. Users also mention the possibility of using alternative software like Igor Pro, which supports log color scaling. Additionally, a specific MATLAB workaround is provided, which involves adjusting the color limits (CLim property) to enhance the visibility of the data by focusing on the "interesting" range and preventing the figure from appearing washed out.
kelvin490
Gold Member
Messages
227
Reaction score
3
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?
 
Physics news on Phys.org
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.
 
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.
 
One possibility is of course to use other software. I, for instance, use Igor Pro for plotting, and it does log color scaling.

Looking around, I found the following: http://ww.mathworks.com/matlabcentral/newsreader/view_thread/152310

The third message, dated 20 Jul, 2007 17:12:42, has a workaround.
 
Last edited by a moderator:
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:
% 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];
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 3 ·
Replies
3
Views
7K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
22K
Replies
2
Views
3K
  • · Replies 0 ·
Replies
0
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K