chris-hld / spaudiopy

Spatial Audio Python Package
https://spaudiopy.readthedocs.io/
MIT License
141 stars 15 forks source link

Most 3D plots don't work with current matplotlib version #23

Closed jr2804 closed 1 year ago

jr2804 commented 2 years ago

Initialization of 3D plot via ax = fig.gca(projection='3d') was declared as deprecated in recent matplotlib version.

(usage of gca() should in general be avoided, when possible)

chris-hld commented 1 year ago

Hi! Thank you for your contribution! I wasn't aware of this issue until now, and switching to plt.axes() seems a good replacement. However, the call ax = plt.axes(fig, projection='3d') with 'fig' as the first argument is not working for me. It works just fine without, though. Can you fix this, or should I go ahead and commit?

chris-hld commented 1 year ago

Actually, I just remembered why the call is fig.gca(). The reasoning is that this makes it possible to pass a custom figure fig, e.g. with certain dimensions, which then gets reused. Therefore, I think that calling a member function of fig is better. In fact, fig.gca() calls Figure.add_subplot, which seems to be the correct way to call explicitly. So I would propose to use fig.add_subplot().

jr2804 commented 1 year ago

So I would propose to use fig.add_subplot().

Yes, that seems to be the best way. My solution was just the one with the least amount of changes :-) I couldn't check yet why I proposed the non-working call to plt.axes(fig, ...) ... actually I only needed one plotting function and modified everything else with search & replace - maybe not the best idea ;-)

I will close this PR and make a new one, thanks!