Rotation of colormap for ellipsoid
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/906085/image.jpeg)
Thank you for your support and time!
0 Commenti
Risposte (2)
Abhishek Chakram
il 16 Nov 2023
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 Commenti
DGM
il 16 Nov 2023
Modificato: DGM
il 16 Nov 2023
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 Commenti
Vedere anche
Categorie
Scopri di più su Camera Views in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!