How to plot a polar plot with theta limited to 180 degrees on both ways
Mostra commenti meno recenti
Hello everyone and thank you for your supportive community.
I have got one issue with polar plots: I am trying to draw a farfield pattern projected onto a "polar" plane (will explain why I put it into quotation marks later). The issue is, in Matlab, the angle θ goes from 0 to 360 degrees. While for the farfield plane cut, we are dealing with spherical coordinates where θ goes from 0 to 180 and ϕ from 0 to 360 (as per the definition of spherical coordinates). Because a cut, in this case, is made by fixing the angle ϕ at given angle (let it be 0 for instance), and then running the angle θ from 0 to 180, then taking the symmetrical ϕ (basically flipping around the axis, or adding 180 degrees), and running θ again from 0 to 180. Basically, the first run gives us half a circle, and the second the second symmetric half.
What I have found to be able to get in matlab is the following figure:

Whereas what I am looking for is something like this:

I realize that in matlab you can change the tick format to 180 which gives one half with θ goes from 0 to 180 and the other half with θ from 0 to -180. But that is not what is explicited in the second figure.
Thanks once again for anyone helping people figure things out.
Risposte (1)
If the negative theta tick values are not desired, you can set the ThetaTickLabels to the absolute value of the current ticks values.
theta = linspace(0,6*pi);
rho1 = theta/10;
ax = polaraxes();
polarplot(ax, -pi:pi/4:pi, 1:9)
ax.ThetaLim = [-180,180];
ax.ThetaZeroLocation = 'top';
5 Commenti
Abdennaser Hadab
il 20 Ott 2022
Adam Danz
il 20 Ott 2022
When your data increase to 180 and then decrease back to 0 such as [177 178 179 180 179 178], that line will not cross into the negative ticks in my answer. There can only be one 179, one 178, etc in the plot.
You can change the TickLabels which is just an aesthetic modification, if needed.
Abdennaser Hadab
il 20 Ott 2022
> So what you are saying is that such a configuration for axes is not possible?
For axis ticks, yes. You can't have duplicate ticks and ticks must be sorted.
However, you can set TickLabels to whatever you want.
Your plan sounds good. Alternatively, instead of using theta data in the range of [0,360], you could use [-180,180] as in my example. Then, when you change the tick labels you just need to apply abs() on the ticks.
Example:
theta = linspace(0,6*pi);
rho1 = theta/10;
ax = polaraxes();
polarplot(ax, -pi:pi/4:pi, 1:9)
ax.ThetaLim = [-180,180];
ax.ThetaZeroLocation = 'top';
ax.ThetaTick = [-180:30:180];
ax.ThetaTickLabels = abs(ax.ThetaTick);
Abdennaser Hadab
il 20 Ott 2022
Categorie
Scopri di più su Polar Plots in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



