Closed isisarantes closed 5 years ago
The simplest way is like this:
from matplotlib import pyplot as plt
plt.savefig("path/to/save.png")
which should save the latest plot produced by matplotlib.
I'm not sure if this works outside of interactive mode. If not, you can grab the matplotlib.Axes
object from the .ax
fieldd of the DemographyPlot
object, then grab the matplotlib.Figure
object from the .fig
field of the Axes object, then call savefig
on that.
Hello, I would like to know if there is a way to save the plots when I'm running momi2 using python and not the Jupyter notebook. I have been trying to run the analyses in the cluster using Jupyter and it is taking so long to run the optimize function and bootstrap, the internet is not stable and I'm not having luck with it. I want to run it using python but I can't save the figures.
yticks = [1e4, 2.5e4, 5e4, 7.5e4,1e5, 2.5e5, 5e5, 7.5e5,1e6, 2.5e6, 5e6, 7.5e6]
fig = momi.DemographyPlot( add_pulse_model3, ["South","North","Central"], figsize=(6,8), major_yticks=yticks, linthreshy=1e5)
I tried to save using: fig.savefig("momi.pdf")
AttributeError Traceback (most recent call last)