How does "polarplot" handle points with radius less than the the lower radial limit set using the "rlim" function in MATLAB?

11 views (last 30 days)
I am using MATLAB R2023b to plot rings on a polar plot by using the "polarplot" function. 
I have used the "rlim" function to set the lower radial limit to 10, and the upper radial limit to 40:
>> rlim([10,40])
However, when I plot rings with radius less than 10, they seem to be plotted in random positions on my plot. For example, a ring with radius 0 is plotted at radius 20. Please see the screenshot below: 
Is this intended behaviour?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 7 Mar 2025
Edited: MathWorks Support Team on 7 Mar 2025
This is the expected behaviour of the "polarplot" function. This behaviour is due to the mathematical principles underlying polar plots, which differ from those of Cartesian plots.
As outlined in the MathWorks documentation for the "polarplot" function, "polarplot" will, by default, reflect negative values through the origin. When you enter the following command:
>> rlim([10,40])
the origin of the polar plot is set to a radius of 10. Consequently, all radius values less than 10 are treated similarly to how negative values would be treated if the origin still had a radius of 0. In this case, values less than 10 are reflected through the new origin of 10 and will appear on the plot.
For example, points with a radius of 0 will be reflected through the new origin of 10 to a radius of 20. Similarly, points with a radius of 5 will be reflected through the origin of 10 to a radius of 15. This behaviour aligns with the mathematical principles of polar plots and is an intended feature specific to polar plots.
To work around this behaviour, it is recommended to filter your data points before plotting, so that all points with a radius less than 10 are removed.
  1 Comment
Adam Danz
Adam Danz on 14 Jan 2025
Here's a demonstration of this oddity. Note that the radial axis limit RLim is [0,1] but the data point at 90 degrees has an RData value of -0.5.
theta = [0 30 60 90 120 150 180];
radius = [1 1 1 -.5 1 1 1];
polarplot(theta*pi/180, radius,'-o','LineWidth',2)

Sign in to comment.

More Answers (0)

Categories

Find more on Polar Plots in Help Center and File Exchange

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!