필터 지우기
필터 지우기

Color by value for 3D curve fitting

조회 수: 4 (최근 30일)
Bob
Bob 2014년 8월 9일
편집: Yu Jiang 2014년 8월 14일
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!

답변 (1개)

Yu Jiang
Yu Jiang 2014년 8월 14일
편집: Yu Jiang 2014년 8월 14일
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

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by