Can't Get ThetaZeroLocation to Work Properly Using polarplot

Hi all,
I have binaural audio measurements made with a head and torso simulator on a turntable. Impulse response were measured for 81 angles at 3° increments (so, 240° to 120° via 0°) to cover the maximum rotation of a human head (and beyond). So, the angle values are a vector ...
Angles = [240:3:357, 0:3:120]; % Vector of angle/azimuth positions
But when I try to plot with the zero location at 'top' (i.e., "north", "12 o'clock", etc.), it stays at the default of 'right. No other directions work either. My feeling is that the ordering of my angles vector is interfering, but I have no idea why - it plots how I'd like, just on its side.
The example here works fine:
... but not with my angle vector as the theta value, which is what leads me to think that's the issue. The full plotting code I'm using (with random numbers for simulated data) is ...
Angles = [240:3:357, 0:3:120]; % Vector of angle/azimuth positions
theta = deg2rad(Angles);
rho = rand(1,81);
ax = polaraxes;
ax.ThetaZeroLocation = 'top';
polarplot(theta,rho);
Many thanks in advance for any advice or suggestions people have. Cheers!

 Respuesta aceptada

Adam Danz
Adam Danz el 4 de Dic. de 2021
Editada: Adam Danz el 4 de Dic. de 2021
You have to either hold the axes after setting ThetaZeroLocation or set ThetaZeroLocation after plotting. Otherwise, when you plot using polarplot it resets the properties.
Angles = [240:3:357, 0:3:120];
Angles = [240:3:357, 0:3:120]; % Vector of angle/azimuth positions
theta = deg2rad(Angles);
rho = rand(1,81);
ax = polaraxes;
ax.ThetaZeroLocation = 'top';
hold(ax, 'on') % <----------- hold
polarplot(theta,rho);

4 comentarios

Fantastic, thank you very much!
Your explanation makes good sense too. I could be wrong, but I think that's the first time I've encountered the need to use 'hold' for changing such an attribute. Perhaps it's specfic to polarplot and somewhere in the general documentation.
Thanks again for a really helpful and concise answer.
Cheers!
Here's another example that sets the direction of the y-axis to reverse, the scale of the x-axis to log, and the color of the axes to blue. All of that is reverted by the plotting function since I did not hold the axes.
I usually do all plotting before I set graphics properties.
ax = axes();
ax.YDir = 'reverse'; % reverse direction of y axis
ax.Color = 'red'; % axis color blue
ax.XScale = 'log'; % set log scale on x axis
plot(ax, 1:5, rand(1,5))
This behavior is not limited to polarplot. High-level plotting functions basically call newplot before they create their lines, surfaces, etc. newplot checks certain figure and axes properties to determine how to prepare the figure and axes for those new lines, surfaces, etc. hold changes those figure and axes properties. See the documentation page for more details.
Peter Beringer
Peter Beringer el 5 de Dic. de 2021
Editada: Peter Beringer el 5 de Dic. de 2021
Thanks both of you for giving me clarification on that. The weird thing is that after getting an answer, I then looked at some other plotting code of mine, I've always specified properties after the plotting function call. Why on earth I thought this needed to be specfied prior I'll never know (stupidity would be a good guess). Oh, well, live and learn ... haha.
Thanks again!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Polar Plots en Centro de ayuda y File Exchange.

Productos

Versión

R2021a

Preguntada:

el 4 de Dic. de 2021

Editada:

el 5 de Dic. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by