MATLAB Answers

How to color/shade a sector of a polar plot with customized axis?

28 views (last 30 days)
matteog
matteog on 5 May 2020
Commented: matteog on 5 May 2020
Dear all,
I have a problem I hope you could help me through. I am trying to obtain a polar plot like this: i.e. with some sectors colored/shaded, let's say between 30 and 60°, but I'd like to be able to do that for any sector I want, and customized axis (labels, ticks etc).
Now, this is the code I ran:
polarplot(theta, rho); %where theta and rho are my angular and radial data
pax=gca;
pax.ThetaTick= 0:45:360
pax.ThetaGrid= 'off'
pax.FontSize= 10
pax.ThetaTickLabel={'Knee Flexion','Inphase (KF - HF)','Hip Flexion','antiphase (HF - KE)','Knee Extension','Inphase (KE - HE)','Hip Extension','Antiphase (HE - KF)'}
pax.FontWeight='bold'
And what I obtain is something like this: I found no way, with gca options, to color/shade a sector, but I could customize all the rest.
Then I tried to use another option: polar instear of polarplot, with the following code:
teta= linspace(13*pi/8,15*pi/8,500);
rho = [0 100*ones(499,1)'];
a = polar(teta,rho)
patch( get(a,'XData'), get(a,'YData'),[0, 0.4470, 0.7410],'FaceAlpha',0.2)
hold on
a=polar(theta2, rho2, 'o')
%where theta and rho are the contour of the sector I'm shading, and Theta2 and Rho2 are the data I'm interested in representing
And what I get is:
Now, the good news is that I obtain my shaded sector, but I am not able to customize the axis or the thetaticks anymore as in the previous figure.
I hoped to combine patch() with polarplot(), but unfortunately it doesn't seem to work.
May someone give me a hand? In previous discussions I found nothing could help me to fix my problem
Thank you in advance!
Matteo

  0 Comments

Sign in to comment.

Accepted Answer

Sean de Wolski
Sean de Wolski on 5 May 2020
Use a polarhistogram and a polarplot (these are newer replacements for polar). This should give you the flexibility you want.

More Answers (0)

Tags


Translated by