Polar plot points appear on wrong position
Show older comments
Hello,
I am plotting values in an array of three parameters (angle, radius, and third parameter which is colored) points with a radius range of [-1.5, 2.8]. When plotting via polarscatter without any axes constraints, they appear as follows. You can see that the datapoint chosen lies at the maximum radius and is correctly placed (2.788 close to the edge of the graph).

If instead of relying on the automatic limits, I run
rlim([-Inf 5])
I can still see the same behaviour:

However, when I try to verify that no points exist beyond 2.8, and run the following:
rlim([3 5])
then, points act strange. As you can see, a point with value R=1.224 and Theta=321 deg appears between 4.5 and 5 ticks on the 150 deg region.

This is what the code looks like:
figure
polaraxes; hold on;
polarscatter(angle_values,r_values,[],extra_values,'.');
% rlim([min max])
My conclusion is that I am not understanding how polar plots really works. This is of course the same if I use polarplot instead of polarscatter. I am going through the documentation to no success to spot my mistake.
Could you help me understand what is going on? Thank you!
Answers (1)
Looks like a bug -- I took the example for polarscatter from the doc and set rlim([10 20])
The one point outside the lower bounds of the new radial limits was still shown...as moved the lower limit to the minimum r value of the smallest point, it looks ok to placing the point at the origin.
But, when the limit is greater than the data point radius value, the angle location is 180 out of phase and the point plotted at a radius was at the reflection of r-rlim(1) --> 6 - 7 = -1.
Looks like the implementation just subtracts the lower limit from the r array and plots the result. This works until the values turn negative.
Doesn't look like was tested very much... :(
5 Comments
This appears to be the result of the default behavior of the polar axes object -- polarplot documents that default action for negative values is to reflect them through the origin and plot positive unless the rlim value is set to include negative values. Thus, when one sets the lower limit to be greater than the minimum; internally it appears that the implementation generates a negative value for display by the rescaling of the input to match the requested range and doesn't test for values not in range, one gets the reflected presentation.
I looked; the m-file dumps all the heavy lifting to the internal p-files that aren't user accessible--so there's no easy user-supplied patch.
Best workaround I see is to use logical addressing and only selectively plot those data >=the rlim(1) value. This could be done by setting those to NaN temporarily in the r data array; of course, one would want to save the original data for restoration if change the limits.
One could write a wrapper routine that does it first before calling the builtin routine so it doesn't get the bum data. Alternatively, altho I didn't investigate, it might be possilbe to link a callback routine to a data change or somesuch that could handle the cleanup.
I'll submit a bug report with this thread as reference...
dpb
on 16 Aug 2020
"I'll submit a bug report with this thread as reference..."
Done.
Mitsu
on 17 Aug 2020
dpb
on 17 Aug 2020
When it hits the official bug list, presuming TMW is willing to concede is a bug, then there is a tracking number...as this went in during non-office hours, all that's happened so far is the robo-reply that the report has been filed...
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!