MATLAB How to Limit Colormap Range in Matlab Scatter Plot?

  • Thread starter Thread starter darkfall13
  • Start date Start date
  • Tags Tags
    Matlab Range
Click For Summary
In Matlab, when creating a scatter plot with a third variable for color representation, users can utilize the scatter function with vectors x, y, and z. The color of the points is controlled by the values in vector z, and the colormap and colorbar can be activated to visualize this. However, if the values in z range widely, such as from -25 to 25, and there is a desire to limit the color mapping to a specific range, like -10 to 10, the "caxis([minvalue maxvalue])" function can be employed. This function effectively sets the color axis limits, ensuring that any values outside the specified range are represented by the last color in the colormap.
darkfall13
Messages
30
Reaction score
0
I'm doing some plotting in Matlab where I'm using a third variable of data as a color. For example I have vectors x and y with some sort of values plotted as a scatter plot. I can color the points according to a third vector z by turning on colormap and colorbar (scatter(X,Y,S,C) and use z in place of C) and Matlab will take care of the color range and scaling.

But let's say z contains random values ranging from -25 to 25 then of course the ends of the colormap will be -25 and 25, but what if you want it to just end at say -10 and 10 so that all values outside of that range are the last color of the colormap?
 
Physics news on Phys.org
I think I found it, using "caxis([minvalue maxvalue])" before colorbar seems to be what I'm looking for.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K