Rotation of colormap for ellipsoid

조회 수: 8 (최근 30일)
Akash V
Akash V 2022년 2월 24일
편집: DGM 2023년 11월 16일
I have plotted the ellipsoid using the surf() function and rotated it based on a condition. However, the colormap on the face of the ellipsoid is not rotating. I have a couple of ellipsoids in a single figure each rotated at different angles. So I need a separate colormap for each ellipsoid rotated w.rt its angle. I have attached a picture of the results I want:
Thank you for your support and time!

답변 (2개)

Abhishek Chakram
Abhishek Chakram 2023년 11월 16일
Hi Akash V,
I understand that you want to have different colormaps for different ellipsoid with respect to its angle. To achieve this, you can use the “colormap” function. It allows to set different colormaps for different axes objects. Here is an example for the same:
tiledlayout(2,1)
ax1 = nexttile;
surf(peaks)
colormap(ax1,spring)
ax2 = nexttile;
surf(peaks)
colormap(ax2,winter)
You can refer to the following documentation to know more about the functions used:
Best Regards,
Abhishek Chakram

DGM
DGM 2023년 11월 16일
편집: DGM 2023년 11월 16일
No code was provided, so we don't know how the objects CData relates to its ZData. We don't know what OP observed or expected, since it's really not clear whether the screenshot is an example of the problem (which is what it appears to be) or if it's an example of the goal (which is what is claimed).
Ether way, creating multiple axes and using a different colormap has nothing to do with the problem or its solution. This is a problem about CData, not the applied colormap.
If you create a surf using only Z or XYZ data, then CData is derived from Z, and CDataMode is 'auto'. If you rotate the surf object, CData will be updated to follow the transformed ZData.
% surf(Z)
% surf(X,Y,Z)
If instead, you explicitly specify CData when creating the surf, then CDataMode is set to 'manual'. In any case, if you want to be able to transform the object without the CData being updated, make sure the CDataMode is 'manual'.
% surf(X,Y,Z,Z)
For example:
[x y z] = sphere(20);
% CData gets updated
hs = surf(x,y,z);
rotate(hs,[1 0 0],-45)
view(-90,0)
% CData doesn't get updated
hs = surf(x,y,z);
hs.CDataMode = 'manual';
rotate(hs,[1 0 0],-45)
view(-90,0)

카테고리

Help CenterFile Exchange에서 Orange에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by