Description
Documentation Link
Problem
In version 3.4, passing keyword arguments to plt.gca()
was deprecated. I was previously using plt.gca(projection='polar')
to:
- Check if a polar projection axes exists, and if so return it
- If not, create a new axes with a polar projection
Looking at the documentation (https://matplotlib.org/stable/users/whats_new.html#changes-to-behavior-of-axes-creation-methods-gca-add-axes-add-subplot) it's not clear to me how to replicate this behaviour however. In pseudo-code I think what I want to do is:
if len(pyplot_axes):
if plt.gca().name != 'polar':
raise RuntimeError('Axes isn't polar projection')
else:
return plt.gca()
else:
return plt.subplot(projection='polar')
The only thing I don't know how to get is a list of pyplot axes (pyplot_axes
above). I looked at https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.html and didn't see anything, but perhaps there's another page I'm missing?
Suggested improvement
Add a clear description to the changelog (https://matplotlib.org/stable/users/whats_new.html#changes-to-behavior-of-axes-creation-methods-gca-add-axes-add-subplot) showing how to write code to reproduce plt.gca(projection=...)
.
Matplotlib Version
3.4.2
Matplotlib documentation version
3.4.2