8000 tight_layout: Import gridspec only on error to remove circular import · matplotlib/matplotlib@6601685 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6601685

Browse files
committed
tight_layout: Import gridspec only on error to remove circular import
1 parent a6f88c8 commit 6601685

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

lib/matplotlib/gridspec.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,8 @@ def tight_layout(self, figure, renderer=None,
303303
fit into. Default is (0, 0, 1, 1).
304304
"""
305305

306-
from .tight_layout import (get_subplotspec_list,
307-
get_tight_layout_figure,
308-
get_renderer)
309-
310-
subplotspec_list = get_subplotspec_list(fig.axes, grid_spec=self)
306+
subplotspec_list = tight_layout.get_subplotspec_list(fig.axes,
307+
grid_spec=self)
311308

312309
if renderer is None:
313310
renderer = tight_layout.get_renderer(figure)

lib/matplotlib/tight_layout.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import warnings
1313

1414
import matplotlib
15-
import matplotlib.gridspec as gridspec
1615
from matplotlib.transforms import TransformedBbox, Bbox
1716

1817
from matplotlib.font_manager import FontProperties
@@ -241,6 +240,7 @@ def get_subplotspec_list(axes_list, grid_spec=None):
241240
warnings.warn("The Axes %s in this figure are not "
242241
"compatible with tight_layout, so its "
243242
"results might be incorrect." % axes_or_locator)
243+
import matplotlib.gridspec as gridspec
244244
subplotspec = gridspec.GridSpec(1, 1)
245245

246246
subplotspec_list.append(subplotspec)

0 commit comments

Comments
 (0)
0