Filter löschen
Filter löschen

How can I re-orient a polar scatter plot so zero is at the top?

114 Ansichten (letzte 30 Tage)
Helen
Helen am 25 Jun. 2021
Kommentiert: Star Strider am 25 Jun. 2021
The default orientation for a polarscatter plot is with the zero to the right hand side and 90 degrees at the top. I have geographical data (so zero degrees is north) and so I want the zero to be at the top and the numbers to increase clockwise. I've looked in all the axis properties but I can't see any way of doing this. I need to use a scatter plot because I want to colour code the markers. Is it possible to re-orient it?

Antworten (2)

Star Strider
Star Strider am 25 Jun. 2021
Use polaraxes properties to do this —
th = rand(1,10)*2*pi; % Angles
r = rand(size(th)); % Radii
figure
polarscatter(th, r, 75, 'filled')
title('Original')
figure
hps = polaraxes; % First, Declare A 'polaraxes' Object & Return Its Handle
polarscatter(th, r, 75, 'filled'); % Then Use 'polarscatter'
hps.ThetaZeroLocation = 'top'; % Change Angle Origin
hps.ThetaDir = 'clockwise'; % Change Angle Direction
title('Desired Result')
I am not certain when these properties were introduced. This works in R2021a.
.
  5 Kommentare
Helen
Helen am 25 Jun. 2021
I'm using 2017b, but ThetaZeroLocation does not exist as a polarscatter property.
Star Strider
Star Strider am 25 Jun. 2021
The ThetaZeroLocation property is not a polarscatter property. It is a polaraxes property. That is the reason I declared polaraxes first, then plotted onto it with polarscatter.
.

Melden Sie sich an, um zu kommentieren.


Chunru
Chunru am 25 Jun. 2021
th = linspace(0,2*pi,20);
r = rand(1,20);
sz = 75;
figure;
subplot(121)
polarscatter(th,r,sz,'filled')
subplot(122)
h = polarscatter(pi/2-th,r,sz,'filled'); % North, Clockwise
thetaTick = h.Parent.ThetaTick;
h.Parent.ThetaTickLabel = string(wrapTo360( 90-thetaTick));
  1 Kommentar
Helen
Helen am 25 Jun. 2021
Thank you. I was hoping that there was a way to do it that didn't involve manually fiddling with everything!

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Polar 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