Hello, the galpy package computes and plots orbits of stars in our galaxy for scientific research.
I am trying render the resulting plots or animations in Streamlit but without success.
The galpy webpage: https://www.galpy.org/
Simple code to implement (this computes and plots our Suns orbit):
from galpy.orbit import Orbit
from galpy.potential import MWPotential2014
from astropy import units as u
import numpy
ts= numpy.linspace(0.,5.,2001)*u.Gyr
o= Orbit() # default = the sun
o.integrate(ts,MWPotential2014)
o.plot(), o.animate()
The o.plot() makes a matplotlib graph, while o.animate() makes a plotly animation.
How can I display these graphs or animation in Streamilt.
I have tried st.pyplot(o.plot()) but it doesn’t work.
It give the error:
AttributeError: 'list' object has no attribute 'savefig'
Full error:
File "/Users/adriancioc/opt/anaconda3/lib/python3.9/site-packages/streamlit/scriptrunner/script_runner.py", line 557, in _run_script
exec(code, module.__dict__)
File "/Users/adriancioc/Desktop/ETCwebApp/webApp.py", line 578, in <module>
st.pyplot(fig = orb)
File "/Users/adriancioc/opt/anaconda3/lib/python3.9/site-packages/streamlit/elements/pyplot.py", line 92, in pyplot
marshall(
File "/Users/adriancioc/opt/anaconda3/lib/python3.9/site-packages/streamlit/elements/pyplot.py", line 132, in marshall
fig.savefig(image, **kwargs)