Description
When plotting a set of data on a polar plot, the default bottom y_limit might not be zero unexpectedly from the perspective of the user, resulting in confusion about the meaning of the plot, especially for a person (like me) unfamiliar with the concept of a polar plot where r=0 is not at the very center point of the plot.
In a Jupyter Notebook
%pylab inline
npoints = 10_000
theta = 360 * random.random(npoints)
r = random.random(npoints)
fig, (ax1, ax2) = subplots(1, 2, figsize=(8, 4), dpi=120, facecolor='white', subplot_kw=dict(projection='polar'))
ax1.plot(radians(theta), r, 'o', markersize=1)
ax1.set_title('expected', pad=12)
ax2.plot(radians(theta), r, 'o', markersize=1)
ax2.set_title('unexpected', pad=12)
ax1.set_ylim(bottom=0)
# ax2.set_ylim(bottom=0)
print(ax2.get_ylim())
>>> (-0.04989219852580686, 1.0497180912808268)
I ran across this when plotting data and wondering if I had a bug in my analysis somewhere that was giving me a hole around the origin. It took me some time to figure out that the problem was simply in the axis scaling as I expected the version on the left (which seems sensible to me as the default) and not the version on the right which has a hole in the middle.
Matplotlib version
- Operating system: Windows 10, also Ubuntu Linux
- Matplotlib version: 3.0.2 from pip
- Matplotlib backend (
print(matplotlib.get_backend())
): inline - Python version: 3.7, 3.6
- Jupyter version (if applicable): JupyterLab 0.35.4