Color by value for 3D curve fitting

9 Ansichten (letzte 30 Tage)
Bob
Bob am 9 Aug. 2014
Bearbeitet: Yu Jiang am 14 Aug. 2014
Say I have x,y, and z vectors.
Using cftool-generated code, I surface fitted the 3D plot via Lowess Quadratic.
In my Z vector, I have positive, zero, and negative values.
I want to make the color of the fitted surface the same for zero and negative Z-values, while for the positive Z-values I want a regular color scale.
How can I customize this way?
Thanks in advance!

Antworten (1)

Yu Jiang
Yu Jiang am 14 Aug. 2014
Bearbeitet: Yu Jiang am 14 Aug. 2014
Hi Bob
You can achieve this by specifying the color data limits. Here is an example I created. By default, when I execute my code generated from cftool, the figure looks like the following:
In order to customize the color data, here is what I would do in the MATLAB command window
>> get(gca, 'CLim')
This gives you the lower and upper limits of the color data. In my example, they are -20 and 15. Now, I run the following command
>> caxis([0, 15])
The function caxis controls the mapping of data values to the color data. Therefore, the above code helps me to reset the limits of the color map. For more details regarding caxis, please refer to
Alternatively, you could use the colormapeditor, which is a MATLAB UI and can give you more customized option to set the colormap. (See the link below for colormap)
1) Type the following in the MATLAB command window and you should be able to see the UI below
>> colormapeditor
2) Change the Color data min field to 0, and click Apply.
Now, the figure should look like the following. I think this is what you would like to achieve.
For more details regarding the colormapeditor, please see
-Yu Jiang

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by