Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitafbe5bb

Browse files
committed
ENH: implement and use base layout_engine for more flexible layout.
1 parentad95791 commitafbe5bb

File tree

12 files changed

+461
-202
lines changed

12 files changed

+461
-202
lines changed

‎doc/api/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ Alphabetical list of modules:
6666
fontconfig_pattern_api.rst
6767
gridspec_api.rst
6868
image_api.rst
69+
layout_engine_api.rst
6970
legend_api.rst
7071
legend_handler_api.rst
7172
lines_api.rst

‎doc/api/layout_engine_api.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
****************************
2+
``matplotlib.layout_engine``
3+
****************************
4+
5+
..currentmodule::matplotlib.layout_engine
6+
7+
..automodule::matplotlib.layout_engine
8+
:members:
9+
:inherited-members:

‎lib/matplotlib/_constrained_layout.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
importnumpyasnp
1919

2020
frommatplotlibimport_api,artistasmartist
21+
frommatplotlib.backend_basesimport_get_renderer
2122
importmatplotlib.transformsasmtransforms
2223
importmatplotlib._layoutgridasmlayoutgrid
2324

@@ -62,7 +63,7 @@
6263

6364

6465
######################################################
65-
defdo_constrained_layout(fig,renderer,h_pad,w_pad,
66+
defdo_constrained_layout(fig,h_pad,w_pad,
6667
hspace=None,wspace=None):
6768
"""
6869
Do the constrained_layout. Called at draw time in
@@ -91,6 +92,7 @@ def do_constrained_layout(fig, renderer, h_pad, w_pad,
9192
layoutgrid : private debugging structure
9293
"""
9394

95+
renderer=_get_renderer(fig)
9496
# make layoutgrid tree...
9597
layoutgrids=make_layoutgrids(fig,None)
9698
ifnotlayoutgrids['hasgrids']:

‎lib/matplotlib/backend_bases.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,7 +2271,7 @@ def print_figure(
22712271
ifbbox_inchesisNone:
22722272
bbox_inches=rcParams['savefig.bbox']
22732273

2274-
if (self.figure.get_constrained_layout()or
2274+
if (self.figure.get_layout_engine()isnotNoneor
22752275
bbox_inches=="tight"):
22762276
# we need to trigger a draw before printing to make sure
22772277
# CL works. "tight" also needs a draw to get the right
@@ -2300,8 +2300,8 @@ def print_figure(
23002300
else:
23012301
_bbox_inches_restore=None
23022302

2303-
# we have already doneCL above, so turn it off:
2304-
stack.enter_context(self.figure._cm_set(constrained_layout=False))
2303+
# we have already donelayout above, so turn it off:
2304+
stack.enter_context(self.figure._cm_set(layout_engine=None))
23052305
try:
23062306
# _get_renderer may change the figure dpi (as vector formats
23072307
# force the figure dpi to 72), so we need to set it again here.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp