From 324633e9c6c7fede3d155b4f9a20d6571a0ec2e8 Mon Sep 17 00:00:00 2001 From: Bryan Rumsey Date: Tue, 9 Nov 2021 12:03:57 -0500 Subject: [PATCH] Added 'auto' option for width and height. --- spatialpy/Result.py | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/spatialpy/Result.py b/spatialpy/Result.py index 42cc1853..75671619 100644 --- a/spatialpy/Result.py +++ b/spatialpy/Result.py @@ -393,12 +393,16 @@ def plot_species(self, species, t_ndx=None, t_val=None, concentration=False, points, data = self.read_step(t_ndx, debug=debug) if use_matplotlib: - import matplotlib.pyplot as plt - - if width is None: - width = 6.4 + width = 6.4 if width in (None, "auto") else width + height = 4.8 if height in (None, "auto") else height + else: + if width in (None, "auto"): + width = None if width == "auto" else 500 if height is None: - height = 4.8 + height = None if height == "auto" else 500 + + if use_matplotlib: + import matplotlib.pyplot as plt if deterministic or not concentration: d = data[spec_name] @@ -417,11 +421,6 @@ def plot_species(self, species, t_ndx=None, t_val=None, concentration=False, plt.plot() return - if width is None: - width = 500 - if height is None: - height = 500 - # map data to types types = {} for i, val in enumerate(data['type']): @@ -664,12 +663,16 @@ def plot_property(self, property_name, t_ndx=None, t_val=None, p_ndx=0, width=No points, data = self.read_step(t_ndx, debug=debug) if use_matplotlib: - import matplotlib.pyplot as plt - - if width is None: - width = 6.4 + width = 6.4 if width in (None, "auto") else width + height = 4.8 if height in (None, "auto") else height + else: + if width in (None, "auto"): + width = None if width == "auto" else 500 if height is None: - height = 4.8 + height = None if height == "auto" else 500 + + if use_matplotlib: + import matplotlib.pyplot as plt if property_name == "type" and included_types_list is not None: coords = [] @@ -697,11 +700,6 @@ def plot_property(self, property_name, t_ndx=None, t_val=None, p_ndx=0, width=No plt.plot() return - if width is None: - width = 500 - if height is None: - height = 500 - from plotly.offline import init_notebook_mode, iplot types = {}