Color by value for 3D curve fitting
4 ビュー (過去 30 日間)
古いコメントを表示
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!
0 件のコメント
回答 (1 件)
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
http://www.mathworks.com/help/matlab/ref/caxis.html http://www.mathworks.com/help/matlab/ref/caxis.html
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
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Surface and Mesh Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!