How to Limit Colormap Range in Matlab Scatter Plot?

  • MATLAB
  • Thread starter darkfall13
  • Start date
  • Tags
    Matlab Range
In summary, the conversation discusses plotting in Matlab using a third variable for color. The speakers mention using the scatter function and the colormap and colorbar options to control the color range and scaling. They also mention using the caxis function to specify the minimum and maximum values for the color range.
  • #1
darkfall13
33
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
  • #2
I think I found it, using "caxis([minvalue maxvalue])" before colorbar seems to be what I'm looking for.
 

FAQ: How to Limit Colormap Range in Matlab Scatter Plot?

1. What is the default range for a Matlab colormap and colorbar?

The default range for a Matlab colormap is from 0 to 1, with 0 being the lowest value and 1 being the highest value. This range can be adjusted by the user if needed.

2. How do I change the range for a specific colormap in Matlab?

To change the range for a specific colormap, you can use the caxis function. This function allows you to specify the minimum and maximum values for the colormap. For example, if you want the range to be from 0 to 10, you would use caxis([0 10]).

3. Can I have different ranges for different colormaps in one plot?

Yes, you can have different ranges for different colormaps in one plot. This can be achieved by using the caxis function and specifying the range for each individual colormap. This is helpful when you have multiple datasets with different value ranges.

4. How can I set a logarithmic scale for the colorbar range in Matlab?

To set a logarithmic scale for the colorbar range in Matlab, you can use the log function. For example, if you want the range to be from 10 to 1000, you would use caxis(log([10 1000])).

5. Is there a way to automatically adjust the colorbar range to fit the data in Matlab?

Yes, there is a way to automatically adjust the colorbar range to fit the data in Matlab. You can use the colorbar('LimitsAutoUpdate','off') function to turn off the automatic range adjustment, and then use the caxis function to manually set the range based on your data.

Similar threads

Replies
1
Views
1K
Replies
8
Views
650
Replies
1
Views
1K
Replies
1
Views
5K
Replies
1
Views
1K
Replies
2
Views
3K
Replies
1
Views
2K
Replies
4
Views
3K
Replies
4
Views
3K
Back
Top