Skip to content

Commit

Permalink
Merge pull request #266 from AstarVienna/fh/plotfix
Browse files Browse the repository at this point in the history
Add iterable_axes to figure_factory
  • Loading branch information
teutoburg authored Sep 5, 2023
2 parents cb345d1 + e775070 commit b7eb725
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion scopesim/effects/surface_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def plot(self, which="x", wavelength=None, *, axes=None, **kwargs):
"""
if axes is None:
fig, axes = figure_factory(len(which), 1)
fig, axes = figure_factory(len(which), 1, iterable_axes=True)
else:
fig = axes.figure
self._axes_guard(which, axes)
Expand Down
6 changes: 2 additions & 4 deletions scopesim/effects/ter_curves.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,7 @@ def plot(self, which="x", wavelength=None, *, axes=None, **kwargs):
"""
if axes is None:
fig, axes = figure_factory(len(which), 1)
# figsize=(10, 5)
fig, axes = figure_factory(len(which), 1, iterable_axes=True)
else:
fig = axes.figure
_guard_plot_axes(which, axes)
Expand Down Expand Up @@ -627,8 +626,7 @@ def plot(self, which="x", wavelength=None, *, axes=None, **kwargs):
"""
if axes is None:
fig, axes = figure_factory(len(which), 1)
# figsize=(10, 5)
fig, axes = figure_factory(len(which), 1, iterable_axes=True)
else:
fig = axes.figure
_guard_plot_axes(which, axes)
Expand Down
3 changes: 3 additions & 0 deletions scopesim/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,10 @@ def close_loop(iterable: Iterable) -> Generator:

def figure_factory(nrows=1, ncols=1, **kwargs):
"""Default way to init fig and ax, to easily modify later."""
iterable_axes = kwargs.pop("iterable_axes", False)
fig, ax = plt.subplots(nrows, ncols, **kwargs)
if iterable_axes and not isinstance(ax, Iterable):
ax = (ax,)
return fig, ax


Expand Down

0 comments on commit b7eb725

Please sign in to comment.