Skip to content

Commit

Permalink
#1413 skip aligning figure if the backend is Template (example tests)
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinsulzer committed Mar 5, 2021
1 parent 0f155f6 commit 07a4763
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions pybamm/plotting/quick_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,14 +616,16 @@ def plot(self, t, dynamic=False):
# Get the position of the top of the legend in relative figure units
# There may be a better way ...
try:
renderer = self.fig.canvas.get_renderer()
except AttributeError:
renderer = None
legend_top_inches = fig_legend.get_window_extent(
renderer=renderer
).get_points()[1, 1]
fig_height_inches = (self.fig.get_size_inches() * self.fig.dpi)[1]
legend_top = legend_top_inches / fig_height_inches
legend_top_inches = fig_legend.get_window_extent(
renderer=self.fig.canvas.get_renderer()
).get_points()[1, 1]
fig_height_inches = (self.fig.get_size_inches() * self.fig.dpi)[1]
legend_top = legend_top_inches / fig_height_inches
except AttributeError: # pragma: no cover
# When testing the examples we set the matplotlib backend to "Template"
# which means that the above code doesn't work. Since this is just for
# that particular test we can just skip it
legend_top = 0
else:
legend_top = 0

Expand Down

0 comments on commit 07a4763

Please sign in to comment.