MCPcopy Create free account
hub / github.com/ColdGrub1384/Pyto / auto_adjust_subplotpars

Function auto_adjust_subplotpars

site-packages/matplotlib/tight_layout.py:37–218  ·  view source on GitHub ↗

Return a dict of subplot parameters to adjust spacing between subplots or ``None`` if resulting axes would have zero height or width. Note that this function ignores geometry information of subplot itself, but uses what is given by the *nrows_ncols* and *num1num2_list* paramete

(
        fig, renderer, nrows_ncols, num1num2_list, subplot_list,
        ax_bbox_list=None, pad=1.08, h_pad=None, w_pad=None, rect=None)

Source from the content-addressed store, hash-verified

35
36
37def auto_adjust_subplotpars(
38 fig, renderer, nrows_ncols, num1num2_list, subplot_list,
39 ax_bbox_list=None, pad=1.08, h_pad=None, w_pad=None, rect=None):
40 """
41 Return a dict of subplot parameters to adjust spacing between subplots
42 or ``None`` if resulting axes would have zero height or width.
43
44 Note that this function ignores geometry information of subplot
45 itself, but uses what is given by the *nrows_ncols* and *num1num2_list*
46 parameters. Also, the results could be incorrect if some subplots have
47 ``adjustable=datalim``.
48
49 Parameters
50 ----------
51 nrows_ncols : Tuple[int, int]
52 Number of rows and number of columns of the grid.
53 num1num2_list : List[int]
54 List of numbers specifying the area occupied by the subplot
55 subplot_list : list of subplots
56 List of subplots that will be used to calculate optimal subplot_params.
57 pad : float
58 Padding between the figure edge and the edges of subplots, as a
59 fraction of the font size.
60 h_pad, w_pad : float
61 Padding (height/width) between edges of adjacent subplots, as a
62 fraction of the font size. Defaults to *pad*.
63 rect : Tuple[float, float, float, float]
64 [left, bottom, right, top] in normalized (0, 1) figure coordinates.
65 """
66 rows, cols = nrows_ncols
67
68 font_size_inches = (
69 FontProperties(size=rcParams["font.size"]).get_size_in_points() / 72)
70 pad_inches = pad * font_size_inches
71 if h_pad is not None:
72 vpad_inches = h_pad * font_size_inches
73 else:
74 vpad_inches = pad_inches
75
76 if w_pad is not None:
77 hpad_inches = w_pad * font_size_inches
78 else:
79 hpad_inches = pad_inches
80
81 if len(num1num2_list) != len(subplot_list) or len(subplot_list) == 0:
82 raise ValueError
83
84 if rect is None:
85 margin_left = margin_bottom = margin_right = margin_top = None
86 else:
87 margin_left, margin_bottom, _right, _top = rect
88 if _right:
89 margin_right = 1 - _right
90 else:
91 margin_right = None
92 if _top:
93 margin_top = 1 - _top
94 else:

Callers 1

get_tight_layout_figureFunction · 0.85

Calls 15

FontPropertiesClass · 0.90
TransformedBboxClass · 0.90
allFunction · 0.85
_get_leftFunction · 0.85
_get_rightFunction · 0.85
_get_topFunction · 0.85
_get_bottomFunction · 0.85
maxFunction · 0.85
sumFunction · 0.85
get_size_in_pointsMethod · 0.80
get_visibleMethod · 0.80
get_size_inchesMethod · 0.80

Tested by

no test coverage detected