Skip to content

Commit

Permalink
ignore pad_aspect for animations
Browse files Browse the repository at this point in the history
temporary solution to #18.  Fixing this once and for all will require writing a custom callback (in callbacks.py) within the resize/zoom to manually pad the datalimits instead of using matplotlib's native behavior for set_aspect like we do now.  But with this temporary fix, pad_aspect=True will be ignored for animations, but the automatic axes limits will still be respected and set correctly.
  • Loading branch information
kecnry committed Sep 17, 2018
1 parent dfacb38 commit 433b32a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
9 changes: 7 additions & 2 deletions autofig/axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,15 +676,20 @@ def meshes(self):

def draw(self, ax=None, i=None, calls=None,
draw_sidebars=True,
show=False, save=False):
show=False, save=False,
in_animation=False):

ax = self._get_backend_object(ax)

# handle aspect ratio
if self.equal_aspect:
aspect = 'equal'
if self.pad_aspect:
adjustable = 'datalim'
if in_animation:
print("WARNING: pad_aspect not supported for animations, ignoring")
adjustable = 'box'
else:
adjustable = 'datalim'
else:
adjustable = 'box'

Expand Down
5 changes: 3 additions & 2 deletions autofig/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ def reset_draw(self):

def draw(self, fig=None, i=None, calls=None,
tight_layout=True, draw_sidebars=True,
show=False, save=False):
show=False, save=False,
in_animation=False):

fig = self._get_backend_object(fig)
callbacks._connect_to_autofig(self, fig)
Expand All @@ -180,7 +181,7 @@ def draw(self, fig=None, i=None, calls=None,
ax = None

axesi.draw(ax=ax, i=i, calls=calls, draw_sidebars=False,
show=False, save=False)
show=False, save=False, in_animation=in_animation)

self._backend_artists += axesi._get_backend_artists()

Expand Down
3 changes: 2 additions & 1 deletion autofig/mpl_animate.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def __call__(self, i):

self.affig.draw(i=i,
tight_layout=self.tight_layout,
draw_sidebars=self.draw_sidebars)
draw_sidebars=self.draw_sidebars,
in_animation=True)

return self.affig._get_backend_artists()

0 comments on commit 433b32a

Please sign in to comment.