How do I rotate or flip a polar plot?

445 Ansichten (letzte 30 Tage)
MathWorks Support Team
MathWorks Support Team am 6 Jul. 2009
Kommentiert: Steven Lord am 1 Jul. 2021
I would like to change the orientation of a polar plot from the default (0 degrees on the right, counterclockwise for increasing angles).

Akzeptierte Antwort

MathWorks Support Team
MathWorks Support Team am 12 Okt. 2020
Bearbeitet: MathWorks Support Team am 8 Dez. 2020
Depending on what function you are using to generate your polar plot, there are different ways to achieve this.
1. If you are using the more recent "polarplot" function:
You can set the theta orientation to certain default values by using the "ThetaZeroLocation" property of the polaraxes object: https://www.mathworks.com/help/matlab/ref/matlab.graphics.axis.polaraxes-properties.html#bu8f1sf_sep_shared-ThetaZeroLocation
This property accepts values of "right", "top", "left", and "bottom".
Additionally, you can simulate setting the "ThetaZeroLocation" to an arbitrary value by changing the "ThetaData" property of the polaraxes' children objects to achieve the desired rotation. (See the attached M file for an example of how to achieve this using a uislider within a UIFigure). Some important things to note when using this approach:
 
  1. If there are any plotted objects whose angular positions are not controlled by the "ThetaData" property (ie, text objects), you will need to adapt their positional properties to be consistent with the polaraxes' coordinates.
  2. Changing the "ThetaData" values for the children objects means that they no longer retain their original values. For example, if the original theta value was 0 and we have rotated it 15 deg, then its new theta value will be 15. To work around this, it is recommended to store the current orientation of the polar axes relative to the "ThetaZeroLocation". This will allow you to get the original data values back
2. If you are using the older "
polar
" function:
The orientation of a plot can be set using the "view" command. For example,
t = 0:0.01:2*pi;
polar(t,sin(2*t).*cos(2*t))
view([180 90])
creates a polar plot with 0 degrees on the left and increasing angles in the counterclockwise direction. Executing the command\n
view([90 -90])
changes the view so that 0 degrees on is at the top of the figure and increasing angles are in the clockwise direction.
 
  6 Kommentare
Adam Danz
Adam Danz am 1 Jul. 2021
The only two ways I'm aware of is by setting orientation using one of the options in my answer or by using the approach outlined in another answer I provided a link to.
Steven Lord
Steven Lord am 1 Jul. 2021
ax = polaraxes;
polarplot(ax, 1:10)
ax.ThetaZeroLocation = 'top';
Do you want the theta direction to be counter-clockwise or do you want 90 degrees to be at the right? You can't have both. If the latter run the last command in the code below (I'm repeating the plot commands so MATLAB Answers will show both polar plots.)
figure
ax = polaraxes;
polarplot(ax, 1:10)
ax.ThetaZeroLocation = 'top';
ax.ThetaDir = 'clockwise'; % 90 degrees at the right

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Polar Plots finden Sie in Help Center und File Exchange

Tags

Noch keine Tags eingegeben.

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by