Skip to content

Commit

Permalink
fix some mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
jklymak committed Mar 31, 2022
1 parent 9d87614 commit a4ca2ca
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
1 change: 1 addition & 0 deletions lib/matplotlib/_tight_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ def auto_adjust_subplotpars(
def get_renderer(fig):
fig._get_cached_renderer()


def get_subplotspec_list(axes_list, grid_spec=None):
"""
Return a list of subplotspec from the given list of axes.
Expand Down
21 changes: 12 additions & 9 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1567,14 +1567,6 @@ def get_default_bbox_extra_artists(self):
bbox_artists.extend(ax.get_default_bbox_extra_artists())
return bbox_artists

def _get_cached_renderer(self):
if self._cachedRenderer is not None:
return self._cachedRenderer
elif hasattr(self.canvas, 'get_renderer'):
return self.canvas.get_renderer()
else:
return _get_renderer(self)

def get_tightbbox(self, renderer=None, bbox_extra_artists=None):
"""
Return a (tight) bounding box of the figure *in inches*.
Expand Down Expand Up @@ -2014,6 +2006,9 @@ def dpi(self):
def dpi(self, value):
self._parent.dpi = value

def _get_cached_renderer(self):
return self._parent._get_cached_renderer()

def _redo_transform_rel_fig(self, bbox=None):
"""
Make the transSubfigure bbox relative to Figure transform.
Expand Down Expand Up @@ -2441,6 +2436,14 @@ def axes(self):

get_axes = axes.fget

def _get_cached_renderer(self):
if self._cachedRenderer is not None:
return self._cachedRenderer
elif hasattr(self.canvas, 'get_renderer'):
return self.canvas.get_renderer()
else:
return _get_renderer(self)

def _get_dpi(self):
return self._dpi

Expand Down Expand Up @@ -2885,7 +2888,7 @@ def draw_without_rendering(self):
Draw the figure with no output. Useful to get the final size of
artists that require a draw before their size is known (e.g. text).
"""
renderer = self._get_cached_renderer()
renderer = _get_renderer(self)
with renderer._draw_disabled():
self.draw(renderer)

Expand Down
2 changes: 0 additions & 2 deletions lib/matplotlib/layout_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
from matplotlib._constrained_layout import do_constrained_layout
from matplotlib._tight_layout import (get_subplotspec_list,
get_tight_layout_figure)
# from matplotlib.backend_bases import _get_renderer
from matplotlib._tight_layout import get_renderer


class LayoutEngine:
Expand Down

0 comments on commit a4ca2ca

Please sign in to comment.