Skip to content

Commit fbaf815

Browse files
authored
Reuse width variable (#6917)
1 parent d797bfb commit fbaf815

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

xarray/plot/facetgrid.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,14 +409,15 @@ def _adjust_fig_for_guide(self, guide):
409409
# Calculate and set the new width of the figure so the legend fits
410410
guide_width = guide.get_window_extent(renderer).width / self.fig.dpi
411411
figure_width = self.fig.get_figwidth()
412-
self.fig.set_figwidth(figure_width + guide_width)
412+
total_width = figure_width + guide_width
413+
self.fig.set_figwidth(total_width)
413414

414415
# Draw the plot again to get the new transformations
415416
self.fig.draw(renderer)
416417

417418
# Now calculate how much space we need on the right side
418419
guide_width = guide.get_window_extent(renderer).width / self.fig.dpi
419-
space_needed = guide_width / (figure_width + guide_width) + 0.02
420+
space_needed = guide_width / total_width + 0.02
420421
# margin = .01
421422
# _space_needed = margin + space_needed
422423
right = 1 - space_needed

0 commit comments

Comments
 (0)