orbital
orbital copied to clipboard
How to get the animation plots working in Mac OS X
I'm attempting to get one of the examples running on a Mac Book Pro running Mac OS X 10.11.4 (El Capitan). What do I need to do to get the plot and plot3d animated plots to function? Please advise.
I can confirm the issue for me, but I'm not sure what the problem is.
Let me see if I can state the problem in another way. I'm trying to reproduce the two animation examples posted at http://pythonhosted.org/OrbitalPy/examples/plotting/plotting/#animation. The file I've attached to this note successfully reproduces all the plots correctly with the exception of the two animation plots. No animated plots are output.
Any advice.
Sam Dupree.
On 4/23/16 19:35:17, Frazer McLean wrote:
I can confirm the issue for me, but I'm not sure what the problem is.
— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/RazerM/orbital/issues/2#issuecomment-213852984
#!/usr/bin/env python
-- coding: utf-8 --
from numpy import radians from scipy.constants import kilo
from orbital import earth, KeplerianElements, Maneuver, plot, plot3d
import matplotlib.pyplot as plt
plt.switch_backend('QT4Agg')
Create molniya orbit from period and eccentricity
from orbital import earth_sidereal_day 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)
Simple plots
plot(molniya)
plot3d(molniya)
Animation
plot(molniya, title='Molniya 1', animate=True)
plot3d(molniya, title='Molniya 2', animate=True)
Maneuvers
man = Maneuver.hohmann_transfer_to_altitude(10000 * kilo)
plot(orbit, title='Maneuver 1', maneuver=man)
plot3d(orbit, title='Maneuver 2', maneuver=man)
import matplotlib.pyplot as plt plt.show()
When I said problem, I meant the bug itself; I understood what you meant.
Any thoughts on the solution to this bug?
The animation works on Matplotlib 1.4.3. I'll need to investigate what changed between 1.4 and 1.5
I traced the problem with git bisect to this commit: matplotlib/matplotlib@03d97f239c2cff6467b9e80e951ea429d96c3be6
So they fixed GC on Python 3 (are you using Python 3?) and we're not storing a reference to the FuncAnimation
instance, so it gets cleaned up.
I'll release a new version to PyPI once I double check my fix against released version of Matplotlib.
I'm using Python 2.7.x. Will that make a difference?
Sam Dupree.
On 6/25/16 19:41:38, Frazer McLean wrote:
I traced the problem with git bisect to this commit: matplotlib/matplotlib@03d97f2 https://github.com/matplotlib/matplotlib/commit/03d97f239c2cff6467b9e80e951ea429d96c3be6
So they fixed GC on Python 3 (are you using Python 3?) and we're not storing a reference to the |FuncAnimation| instance, so it gets cleaned up.
I'll release a new version to PyPI once I double check my fix against released version of Matplotlib.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/RazerM/orbital/issues/2#issuecomment-228576069, or mute the thread https://github.com/notifications/unsubscribe/AEjt9xdSZPw0viLMNb8tgP2vAkjDgNEkks5qPbyygaJpZM4IMS93.
I'll check there too. Might mean it was always broken on Python 2.7.
For now, you can get it to work by keeping a reference to the result of plot()
:
_ = plot(molniya, title='Molniya 1', animate=True)
I'm still a novice when it comes to Python, so would you explain syntax of the _ = and what the statement _ = plot(molniya, title='Molniya 1', animate=True) does?
Thanks.
@OrbitalMechanic the above merely means that you've instantiated the variable _
which assigns and holds the value of plot(molniya, title='Molniya 1', animate=True)
. From my understanding here there was some sort of latent cleanup which is where the issue is arising from. If I were you I would attempt to upgrade to Python 3.X and try. If @RazerM is able to resolve the issue in Python 3.X then I would go with that.
I also came across this library just today so I will try my best to reproduce and write back here in due course regarding any issues I encounter.
Any results on solving this issue? I cannot generate any of the plots to generate in mac with python 2.7
I am able to generate the plots by including the following:
import matplotlib.pyplot as plt
and right after the plot command the plt.show()
command:
plot(molniya, title='Molniya 1', animate=True)
plt.show()
However, the plots are static, but I cannot get the animation to work.
I've been away from orbital for some time now and am coming back to it. Presently, I'm running Python ver. 3.6.5 under the Anaconda distribution on a Mac Pro (desktop, Late 2012) running Mac OS X ver. 10.12.6 (Sierra).
The issue I'm having with getting animation working is that I can get an animated plot, but I cannot save the animation as a *.mp4 file. The desired output file is allocated, but nothing is output to it.
The output I get from Python is as follows.
**/Users/user/.bash_profile: line 479: /Applications/mesasdk/bin/mesasdk_init.sh: No such file or directory
/Users/user/.bash_profile: line 485: /Applications/madsdk/bin/madsdk_init.sh: No such file or directory
Traceback (most recent call last):
File "/Users/user/orbital/Keplerain Orbit Trajectory Plots - OrbitalPy(python2)/OrbitalPy_StateVector.py", line 66, in
The Python program I'm running is contained in the attached file.
Any thoughts?
I believe I found a workaround form the discussion posted at https://stackoverflow.com/questions/23856990/cant-save-matplotlib-animation. I added the path for ffmpeg on my system to my code as seen in the file attached to this posting and it now saves the .mp4 file.
Hope this helps.