[obspy-users] Saving plot_trigger figures

Tobias Megies megies at geophysik.uni-muenchen.de
Sat Mar 4 12:30:54 CET 2017


You're right, the plot_trigger() function should probably return the
created figure.. but with a bit of matplotlib you can easily grab the
last figure created and work around this obspy API mishap.. try this:


import matplotlib.pyplot as plt
for ... in ...:
    plot_trigger(..., show=False)
    fig = plt.gcf()
    fig.savefig(...)
    plt.close(fig)


cheers!
T


On 03/03/2017 10:19 PM, Michael J. Herrman wrote:
> This is probably an easy question for those more experienced with obspy
> and python but I am having some trouble trying to figure out how to save
> the plot generated by the plot_trigger function without manually saving
> the plot when it is shown.  
> 
> 
> Im planning on having a while loop that calls each trace in a stream
> separately then runs plot_trigger. Id like the save the plots without
> them being shown so ive set show=False in plot_trigger.  There is no
> outfile option in the plot_trigger command and I am not sure how else to
> save it.  Hoping someone might be able to help me out with this.
> 
> Thanks!
> 
> 
> _______________________________________________
> obspy-users mailing list
> obspy-users at lists.swapbytes.de
> http://lists.swapbytes.de/mailman/listinfo/obspy-users
> 

-- 
Dipl.-Geophys. Tobias Megies

EMail: tobias.megies at lmu.de
WWW: https://www.geophysik.uni-muenchen.de

Geophysikalisches Observatorium
Ludwigshöhe 8
82256 Fürstenfeldbruck

Tel: +49 (0) 89 2180-73981
Fax: +49 (0) 89 2180-73970

Ludwig-Maximilians-Universität
Department für Geo- und Umweltwissenschaften
Sektion Geophysik
Theresienstrasse 41/IV
80333 München

Tel: +49 (0) 89 2180-4326
Fax: +49 (0) 89 2180-4205


More information about the obspy-users mailing list