soft-matter / trackpy

Python particle tracking toolkit
http://soft-matter.github.io/trackpy
Other
437 stars 131 forks source link

`plot_traj3d` throws error #759

Closed jacopoabramo closed 1 month ago

jacopoabramo commented 3 months ago

We're currently using tp.plot_traj3d for plotting a 3D trajectory. Here plt.gca is broken. This is due to deprecation with the latest matplotlib library, as stated in this post.

I fixed it locally by monkeypatching the following:

if not hasattr(plt.gca(), 'zaxis'):
    plt.figure()  # initialize new Fig when current axis is not 3d
kwargs['ax'] = plt.gca(projection='3d')

with

 kwargs['ax'] = plt.subplot(projection='3d')

Don't know if issue is duplicate; if not I can try making a PR. I didn't inspect the rest of the code so don't know if it affects the rest of the wrapper.