Skip to content

Commit

Permalink
More
Browse files Browse the repository at this point in the history
  • Loading branch information
Cadair committed Nov 10, 2024
1 parent 42a3e51 commit 0a5599e
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions mpl_animators/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,6 @@ def __init__(self, data, slider_functions, slider_ranges, fig=None,
self.button_labels = button_labels or []
self.num_buttons = len(self.button_func)

if not fig:
fig = plt.figure(layout="constrained")
self.parent_fig = fig
self.subfigs = None
self._setup_subfigure_grid()
self.fig = self.subfigs[0]

self.data = data
self.interval = interval
self.if_colorbar = colorbar
self.imshow_kwargs = kwargs

if len(slider_functions) != len(slider_ranges):
raise ValueError("slider_functions and slider_ranges must be the same length.")

Expand All @@ -114,6 +102,18 @@ def __init__(self, data, slider_functions, slider_ranges, fig=None,
self.slider_ranges = slider_ranges
self.slider_labels = slider_labels or [''] * len(slider_functions)

if not fig:
fig = plt.figure(layout="constrained")
self.parent_fig = fig
self.subfigs = None
self._setup_subfigure_grid()
self.fig = self.subfigs[0]

self.data = data
self.interval = interval
self.if_colorbar = colorbar
self.imshow_kwargs = kwargs

# Set active slider
self.active_slider = 0

Expand All @@ -130,8 +130,8 @@ def __init__(self, data, slider_functions, slider_ranges, fig=None,
#
# Only do this if figure has a manager, so directly constructed figures
# (ie. via matplotlib.figure.Figure()) work.
if hasattr(self.fig.canvas, "manager") and self.fig.canvas.manager is not None:
plt.sca(self.axes)
# if isinstance(self.axes, mpl.axes.Axes) and hasattr(self.fig.canvas, "manager") and self.fig.canvas.manager is not None:
# plt.sca(self.axes)

# Do Plot
self.im = self.plot_start_image(self.axes)
Expand Down Expand Up @@ -325,6 +325,7 @@ def _add_widgets(self):
sframe.cval = sframe.val
saxis._slider = sframe

# Add the label as text in the middle of the axis
saxis.text(
0.5,
0.5,
Expand Down

0 comments on commit 0a5599e

Please sign in to comment.