color of marks in polar plot

I want to make a polar plot. I have 16 pair of values and want to show them with markers as their colors changes gradually from pair 1 to pair 16. Could you please help me?

 Réponse acceptée

Matt Fig
Matt Fig le 30 Avr 2011

0 votes

Walter hit on the only solution that makes sense to me. It is not that bad, for instance:
% Sample Data...
A = linspace(0,2*pi,16);
B = A.^2;
mat = repmat((0:1/15:1).',1,3);
polar(A,B);hold on % If you want a connecting line.
for ii = 16:-1:1
L(ii) = polar(A(ii),B(ii),'o');
hold on
set(L(ii),'markerfacecolor',mat(ii,:),...
'markeredgecolor',mat(ii,:))
end

6 commentaires

Hassan
Hassan le 30 Avr 2011
thanks Matt. I ran your code but it showed a polar plot with a line. I changed it to polar(A,B,'*') to show the values with a marker. the color of the markers didn't change. am I missing something?
Matt Fig
Matt Fig le 1 Mai 2011
I think you did miss something, because I just copied and pasted the above code into MATLAB and got a blue line connecting dots of various colors ranging from black in the center to white at the edge. So, did you mean that you tried to adapt the above code and it didn't produce the results I describe, or that my exact code didn't do what I describe?
Matt Fig
Matt Fig le 1 Mai 2011
Leave out the line I indicated if you don't want the blue line connecting the dots...
Hassan
Hassan le 1 Mai 2011
thanks a lot Matt. I ran your code again and is working fine now, I think I was doing something wrong before.
About the connecting line, I don't want it but the problem is if I don't use it then some of the markers fall out of the polar plot.
If want to assaign a different color to each marker, what should I do? I looked at the 'colorspec' but it seems it has a few colors (8 colors).
Matt Fig
Matt Fig le 1 Mai 2011
The dots are still there, but you wanted to go from black to white. Thus the final few are nearly white and don't show up well. To avoid this you could either change the axis color to introduce contrast, or change the range of the dots' color. For example:
mat = repmat((0:.7/15:.7).',1,3);
which would go from black to grey.
Hassan
Hassan le 1 Mai 2011
thanks Matt.

Connectez-vous pour commenter.

Plus de réponses (1)

Walter Roberson
Walter Roberson le 30 Avr 2011

0 votes

polar() the entire vector first. Then "hold on" and iterate through the theta/rho pairs polar()'ing each pair individually with the marker and color that you want for that point.

5 commentaires

Hassan
Hassan le 30 Avr 2011
thanks Walter. I wondered if there is a way to just define a color like black and white and then the color of all the marks change from black to white or something like that whithout defining seperate color for each pair of values.
Walter Roberson
Walter Roberson le 30 Avr 2011
No. polar() plots use line or lineseries objects to draw the lines, and line and lineseries objects are restricted to a single marker color per object. In order to have multiple marker colors, there has to be multiple objects.
Hassan
Hassan le 30 Avr 2011
thanks Walter. I'll let this question to be open in the case another solution comes up, hopefully.
Walter Roberson
Walter Roberson le 30 Avr 2011
Well, you could interpolate (calculate) the colors you pass to polar() instead of using color letters.
You could polar() in the lines all at one time, and then you could convert the polar coordinates to cartesian and scatter() in the points, specifying a matrix of colors.
You could polar() in the lines all at one time, and then you could convert the polar coordinates to cartesian and then you could use patch() to draw very thin lines, and use vertex shading in the patch()
Hassan
Hassan le 30 Avr 2011
thanks Wlater. it sounds a bit complicated for me but I think Matt got what you suggested and I'll see if I can use that.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Polar Plots dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by