| Server IP : 35.80.110.71 / Your IP : 216.73.216.52 Web Server : Apache/2.4.58 (Ubuntu) System : Linux ip-172-31-21-44 6.17.0-1019-aws #19~24.04.1-Ubuntu SMP Tue Jun 23 18:53:06 UTC 2026 x86_64 User : ubuntu ( 1000) PHP Version : 8.3.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /usr/lib/python3/dist-packages/matplotlib/__pycache__/ |
Upload File : |
�
G8�cdt � � � d Z ddlZddlZddlmZmZ ddlm Z
ddlmZ
ej e� Z dd�Zdd�Zd� Zd� Zd� Zddddd �d
�Zddddd �d�Zddd�d
�Zd� Zd� Zd� Zddddd �d�Zdd�d�Zd� Zd� Zy)aB
Adjust subplot layouts so that there are no overlapping axes or axes
decorations. All axes decorations are dealt with (labels, ticks, titles,
ticklabels) and some dependent artists are also dealt with (colorbar,
suptitle).
Layout is done via `~matplotlib.gridspec`, with one constraint per gridspec,
so it is possible to have overlapping axes if the gridspecs overlap (i.e.
using `~matplotlib.gridspec.GridSpecFromSubplotSpec`). Axes placed using
``figure.subplots()`` or ``figure.add_subplots()`` will participate in the
layout. Axes manually placed via ``figure.add_axes()`` will not.
See Tutorial: :doc:`/tutorials/intermediate/constrainedlayout_guide`
General idea:
-------------
First, a figure has a gridspec that divides the figure into nrows and ncols,
with heights and widths set by ``height_ratios`` and ``width_ratios``,
often just set to 1 for an equal grid.
Subplotspecs that are derived from this gridspec can contain either a
``SubPanel``, a ``GridSpecFromSubplotSpec``, or an ``Axes``. The ``SubPanel``
and ``GridSpecFromSubplotSpec`` are dealt with recursively and each contain an
analogous layout.
Each ``GridSpec`` has a ``_layoutgrid`` attached to it. The ``_layoutgrid``
has the same logical layout as the ``GridSpec``. Each row of the grid spec
has a top and bottom "margin" and each column has a left and right "margin".
The "inner" height of each row is constrained to be the same (or as modified
by ``height_ratio``), and the "inner" width of each column is
constrained to be the same (as modified by ``width_ratio``), where "inner"
is the width or height of each column/row minus the size of the margins.
Then the size of the margins for each row and column are determined as the
max width of the decorators on each axes that has decorators in that margin.
For instance, a normal axes would have a left margin that includes the
left ticklabels, and the ylabel if it exists. The right margin may include a
colorbar, the bottom margin the xaxis decorations, and the top margin the
title.
With these constraints, the solver then finds appropriate bounds for the
columns and rows. It's possible that the margins take up the whole figure,
in which case the algorithm is not applied and a warning is raised.
See the tutorial doc:`/tutorials/intermediate/constrainedlayout_guide`
for more discussion of the algorithm with examples.
� N)�_api�artistc
�H � | j � }t | d|�� }|d st j d� yt d� D ]� } t || |||||�� t
|| |||�� t || � || j � d}
t || � rht || |||||�� |rit || � }|| j � t || � rt || |||||�� n+t j |
� nt j |
� t || � �� |S ) aQ
Do the constrained_layout. Called at draw time in
``figure.constrained_layout()``
Parameters
----------
fig : Figure
``Figure`` instance to do the layout in.
renderer : Renderer
Renderer to use.
h_pad, w_pad : float
Padding around the axes elements in figure-normalized units.
hspace, wspace : float
Fraction of the figure to dedicate to space between the
axes. These are evenly spread between the gaps between the axes.
A value of 0.2 for a three-column layout would have a space
of 0.1 of the figure width between each column.
If h/wspace < h/w_pad, then the pads are used instead.
rect : tuple of 4 floats
Rectangle in figure coordinates to perform constrained layout in
[left, bottom, width, height], each from 0-1.
compress : bool
Whether to shift Axes so that white space in between them is
removed. This is useful for simple grids of fixed-aspect Axes (e.g.
a grid of images).
Returns
-------
layoutgrid : private debugging structure
N)�rect�hasgridszhThere are no gridspecs with layoutgrids. Possibly did not call parent GridSpec with the "figure" keyword� )�h_pad�w_pad�hspace�wspace)r r
z{constrained_layout not applied because axes sizes collapsed to zero. Try making figure larger or axes decorations smaller.)
�
_get_renderer�make_layoutgridsr �
warn_external�range�make_layout_margins�make_margin_suptitles�match_submerged_margins�update_variables�check_no_collapsed_axes�reposition_axes�compress_fixed_aspect�
reset_margins)�figr r
r r r �compress�renderer�layoutgrids�_�warn_collapseds �@/usr/lib/python3/dist-packages/matplotlib/_constrained_layout.py�do_constrained_layoutr ? s@ � �N � � �"�H�"�3��4�8�K��z�"���� /� 0� �
�1�X� %(�� �K��h�e�"'��v� G��k�3���$)� +� ��S�1� �C��)�)�+�G�� #�;��4��K��h�e�"'��v�
G��3�K��E���C� �1�1�3�*�;��<�#�K��h�e�*/��v�O� �&�&�~�6����~�.��k�3�'�K%(�L �� c �& � |�t � }d|d<