Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with 3D plots #16

Open
calumpark opened this issue Feb 17, 2020 · 2 comments
Open

Problem with 3D plots #16

calumpark opened this issue Feb 17, 2020 · 2 comments

Comments

@calumpark
Copy link

When trying to plot a 3D graph I am getting the error message 'NameError: name 'plot3d' is not defined' when using code 'plot3d(molniya)' as it is provided in the examples. I'm using Python 2.7. Is there extra code I'm missing the plot this graph or is it a problem within Orbital?

I've also tried using 'from mpl_toolkits import mplot3d' then
ax = plt.axes(projection='3d')
ax.plot3D(molniya)'
but this returns an error 'TypeError: plot() takes at least 3 arguments (2 given)'

Any help would be appreciated.

@garbagetrash
Copy link
Contributor

I've included minimal working code for my setup using python 3.8.10, numpy 1.21, and matplotlib 3.4.2 below. That being said, I had to edit the plotting.py file a bit to make it work (PR incoming), and the animate feature still isn't working for me. The fixes in plotting.py are just wrapping the number of points parameters in the numpy.linspace() calls with an int() typecast since that's what numpy expects (vs floats.)

$ cat plot3d.py 
from numpy import radians
from scipy.constants import kilo

from orbital import earth, KeplerianElements, Maneuver, plot, plot3d

from orbital import earth_sidereal_day

import matplotlib.pyplot as plt

molniya = KeplerianElements.with_period(
    earth_sidereal_day / 2, e=0.741, i=radians(63.4), arg_pe=radians(270),
    body=earth)

# Simple circular orbit
orbit = KeplerianElements.with_altitude(1000 * kilo, body=earth)

plot3d(molniya)
plt.show()

@RazerM
Copy link
Owner

RazerM commented Jul 28, 2021

I've merged #22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants