Rotation of colormap for ellipsoid
8 次查看(过去 30 天)
显示 更早的评论
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!
0 个评论
回答(2 个)
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
0 个评论
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)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Orange 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!