How can I get surf or pcolor to be colored properly?

10 visualizaciones (últimos 30 días)
I have a set of data that represents coloring on a sphere. I want to project half of that data onto a circle. I'm trying to use pcolor and surf (according to the documentation on pcolor), but it seems that no matter what I do the circle just ends up being a solid color. Here is a sample of what my code would look like:
rho1(size(C1,1)) = 1;
theta_c1 = linspace(0,2*pi,size(C1,2));
[theta_c1,rho1] = meshgrid(theta_c1,rho1);
[xc1,yc1] = pol2cart(theta_c1,rho1);
surf(xc1,yc1,zeros(size(xc1)),C1,'Edgecolor','None');
C1 is taken from my data and represents the color data for surf or pcolor. If I just do pcolor(C1), then the colors turn out exactly how I would expect them to, except that they are not on a circle.
Thanks in advance.

Respuesta aceptada

Chandler Williams
Chandler Williams el 7 de Jun. de 2017
I found a solution. It turned out that the problem was that I was only using one radius value for rho1 instead of a list of values. When I changed it to a list of values (i.e. rho1 = linspace(0,1,num_vals)) before doing meshgrid and the conversion from polar to Cartesian coordinates it worked.

Más respuestas (1)

KSSV
KSSV el 6 de Jun. de 2017
You have C1 in the Cartesian coordinates and xc1, yc1 in polar coordinates. YOu have to change C1 into polar coordinates. Do interpolation, doc interp2.
  1 comentario
Chandler Williams
Chandler Williams el 6 de Jun. de 2017
Interp2 would change the values in C1, which isn't what I want. The C1 values are actually from a globe in spherical coordinates and xc1 and yc1 are in Cartesian coordinates (they are calculated using pol2cart with theta being an array of angles and r being an array of ones. This allows me to create a unit circle). To do the surface plot, they need to be in Cartesian coordinates, but the values that I'm using for the color shouldn't change at all as they are calculated from specific functions and should represent a specific value at a point on the circle whether in spherical or Cartesian coordinates.
Thanks.

Iniciar sesión para comentar.

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by