Filter löschen
Filter löschen

How can I change the color of tiles in a spherical graph?

8 Ansichten (letzte 30 Tage)
Vítek
Vítek am 29 Mär. 2023
Bearbeitet: daniel mitchell am 29 Mär. 2023
Hello,
I need to change color of every tile, so the sphere is a heat map just like this image.
This is just image that we got from our teacher, but i have no clue how to make it.

Antworten (2)

Adam Danz
Adam Danz am 29 Mär. 2023
Bearbeitet: Adam Danz am 29 Mär. 2023
sphere
axis equal
colorbar
If you want to change the colors, you can plot the sphere using surf(X,Y,Z,C) where C controls color of each face.
Use the [X,Y,Z] = sphere syntax to return the x,y,z coordinates and then use h=surf(X,Y,Z) to produce the same sphere and return the surface handle. You can also control color by updating properties of the surface object h.

daniel mitchell
daniel mitchell am 29 Mär. 2023
Bearbeitet: daniel mitchell am 29 Mär. 2023
In S1 you can see the properties.
You can use the Cdata propery to change the color of each tile for example.
[X,Y,Z] = sphere;
figure
s1 = surf(X,Y,Z)
s1 =
Surface with properties: EdgeColor: [0 0 0] LineStyle: '-' FaceColor: 'flat' FaceLighting: 'flat' FaceAlpha: 1 XData: [21×21 double] YData: [21×21 double] ZData: [21×21 double] CData: [21×21 double] Show all properties
colorbar;
axis equal
figure;
s2 = surf(X,Y,Z)
s2 =
Surface with properties: EdgeColor: [0 0 0] LineStyle: '-' FaceColor: 'flat' FaceLighting: 'flat' FaceAlpha: 1 XData: [21×21 double] YData: [21×21 double] ZData: [21×21 double] CData: [21×21 double] Show all properties
s2.CData = zeros(21,21,3);
s2.CData(12,3,:) = [1 0 0] % R G B
s2 =
Surface with properties: EdgeColor: [0 0 0] LineStyle: '-' FaceColor: 'flat' FaceLighting: 'flat' FaceAlpha: 1 XData: [21×21 double] YData: [21×21 double] ZData: [21×21 double] CData: [21×21×3 double] Show all properties

Kategorien

Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by