aerospaceresearch / orbitdeterminator

determination of satellite orbits and more
MIT License
181 stars 113 forks source link

plot_kep breaks with recent matplotlib #188

Open craigim opened 4 years ago

craigim commented 4 years ago

When I try to use plot_kep, I get :

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-119-76c4fc158eb2> in <module>
----> 1 plot_kep(kep, data[:, 1:4])

~/anaconda3/lib/python3.7/site-packages/orbitdeterminator-1.0-py3.7.egg/orbitdeterminator/kep_determination/ellipse_fit.py in plot_kep(kep, data)
    386     fig = plt.figure()
    387     ax = Axes3D(fig)
--> 388     ax.axis('equal')
    389 
    390     # plot

~/anaconda3/lib/python3.7/site-packages/matplotlib/axes/_base.py in axis(self, *args, **kwargs)
   1675                 # self.apply_aspect()
   1676                 if s == 'equal':
-> 1677                     self.set_aspect('equal', adjustable='datalim')
   1678                 elif s == 'scaled':
   1679                     self.set_aspect('equal', adjustable='box', anchor='C')

~/anaconda3/lib/python3.7/site-packages/matplotlib/axes/_base.py in set_aspect(self, aspect, adjustable, anchor, share)
   1279         if (not cbook._str_equal(aspect, 'auto')) and self.name == '3d':
   1280             raise NotImplementedError(
-> 1281                 'It is not currently possible to manually set the aspect '
   1282                 'on 3D axes')
   1283 

NotImplementedError: It is not currently possible to manually set the aspect on 3D axes

It appears to be related to matplotlib/matplotlib#1077 where, rather than fixing an issue with setting the aspect ratio, they instead just shut off the feature.

Allan-Perez commented 4 years ago

I have tried it, and you're right. It seems to be an open issue within the matplotlib library. I suggest to put it as a try-except block, trying the matplotlib function, but if there's this error (NotImplementedError), then try another way. This way would be to put a numerical limit on the axes, where these limits would be the largest (and smallest) value of all the axes, and then set it to all of the axes (original idea of tauran). I tried it with the orbit.csv dataset, and it seems to work just fine. I'll do a pull request so that they can test it and improve it further.

tacaswell commented 4 years ago

Setting the aspect of 3D plots never actually worked (which is why we now raise NotImplemented).

hornig commented 3 years ago

@tacaswell @craigim @Allan-Perez can we close this issue?