Borrar filtros
Borrar filtros

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

114 visualizaciones (últimos 30 días)
Helen
Helen el 25 de Jun. de 2021
Comentada: Star Strider el 25 de Jun. de 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?

Respuestas (2)

Star Strider
Star Strider el 25 de Jun. de 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 comentarios
Helen
Helen el 25 de Jun. de 2021
I'm using 2017b, but ThetaZeroLocation does not exist as a polarscatter property.
Star Strider
Star Strider el 25 de Jun. de 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.
.

Iniciar sesión para comentar.


Chunru
Chunru el 25 de Jun. de 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 comentario
Helen
Helen el 25 de Jun. de 2021
Thank you. I was hoping that there was a way to do it that didn't involve manually fiddling with everything!

Iniciar sesión para comentar.

Categorías

Más información sobre Polar Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by