2
votes

polar(theta,r) and polarplot(theta,r) are both polar plots in MATLAB.

The former is the old standard, the latter was introduced in R2016. Does anyone know why, or what the difference is?

I can't see any major differences in MATLAB's doc pages, so I am surprised that they maintained two commands rather than silently updating the code for polar

1

1 Answers

3
votes

I can't check the code of the new one as I have too old MATLAB here (2015a), but from the doc glance it seems it actually plots data points in the circle directly. The old one transforms polar data to xy and plots all the rest (circles, spokes and labels) on the image. This means old polar can for example be used as:

r = 1:100;
theta = 1:100;
polar(theta, r)
hold on
plot(r)

This will draw a weird spiral plus a line going from center to top right corner (and outside of polar boundaries). Not sure how common is this in code out there, but I could see why Mathworks didn't want to give a "proper" polar plot that would break existing code - from the doc glance it seems the above is not possible with the new polarplot (last tip: To plot additional data in the polar axes, use the hold on command. However, you cannot plot data that requires Cartesian axes in a polar chart.)