From abb9bd47e14d2c2d469aac73f1bf6b5a6b9d16c0 Mon Sep 17 00:00:00 2001 From: bch0w Date: Tue, 28 Feb 2023 16:17:48 -0900 Subject: [PATCH] moved plt close statements into manager because it was prematurely closing figures for the 'both' option --- pyatoa/core/manager.py | 6 ++++-- pyatoa/visuals/map_maker.py | 2 -- pyatoa/visuals/wave_maker.py | 2 -- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/pyatoa/core/manager.py b/pyatoa/core/manager.py index a0a962ff..26bcfff4 100755 --- a/pyatoa/core/manager.py +++ b/pyatoa/core/manager.py @@ -4,6 +4,8 @@ """ import os import obspy +import matplotlib as mpl +import matplotlib.pyplot as plt import numpy as np import pyflex import pyadjoint @@ -1245,15 +1247,15 @@ def plot(self, choice="both", save=None, show=True, corners=None, if choice == "wav": wm = WaveMaker(mgmt=self, **kwargs) wm.plot(show=show, save=save) + plt.close() # Plot only map elif choice == "map": mm = MapMaker(inv=self.inv, cat=self.event, corners=corners, **kwargs) mm.plot(show=show, save=save) + plt.close() # Plot waveform and map on the same figure elif choice == "both": - import matplotlib as mpl - import matplotlib.pyplot as plt if figsize is None: figsize = (1400 / dpi, 600 / dpi) diff --git a/pyatoa/visuals/map_maker.py b/pyatoa/visuals/map_maker.py index 36f40aa4..af95a7c8 100644 --- a/pyatoa/visuals/map_maker.py +++ b/pyatoa/visuals/map_maker.py @@ -364,8 +364,6 @@ def plot(self, show=True, save=None, **kwargs): plt.savefig(save) if show: plt.show() - else: - plt.close() def scale_bar(ax, length=None, location=(0.85, 0.95), linewidth=3, diff --git a/pyatoa/visuals/wave_maker.py b/pyatoa/visuals/wave_maker.py index 5ad942c7..3561ce57 100644 --- a/pyatoa/visuals/wave_maker.py +++ b/pyatoa/visuals/wave_maker.py @@ -690,8 +690,6 @@ def plot(self, show=True, save=False, **kwargs): plt.savefig(save) if show: plt.show() - else: - plt.close() def align_yaxes(ax1, ax2):