rL i1\dZddlZddlZddlmZmZddlm Z ddl m Z  d dZ d dZ d dZy) a Routines to adjust subplot params so that subplots are nicely fit in the figure. In doing so, only axis labels, tick labels, Axes titles and offsetboxes that are anchored to Axes are currently considered. Internally, this module assumes that the margins (left margin, etc.) which are differences between ``Axes.get_tightbbox`` and ``Axes.bbox`` are independent of Axes position. This may fail if ``Axes.adjustable`` is ``datalim`` as well as such cases as when left or right margin are affected by xlabel. N)_apiartist)FontProperties)Bboxc  |\} } ttjdjdz } || z} ||| zn| }||| zn| }t |t |k7st |dk(rt | dx}x}x}}n| \}}}}|rd|z nd}|rd|z nd}t j| dz| f}t j| | dzf}|B|Dcgc]5}tj|Dcgc]}|jdc}7}}}t|||D]O\}}\}}td |Drg}|D]-}|js|tj||gz }/tj|}|j j#j%|}|||j&fxx|j(|j(z z cc<|||j*fxx|j,|j,z z cc<||j&|fxx|j.|j.z z cc<||j*|fxx|j0|j0z z cc<R|j3\} }!|st5|dddfj5d| | z z}|j6}"|"r]|"j9rM|j j#j%|"j;|j<}#||#| | z zz }|s't5|ddd fj5d| | z z}|st5|dddfj5d| |!z z}|j>rq|j>j9rW|j j#j%|j>j;|j@}$||$| |!z zz }|st5|d ddfj5d| |!z z}|jB}"|"r]|"j9rM|j j#j%|"j;|j@}$||$| |!z zz }||zdk\rtEjFd y||zdk\rtEjFd ytI|d|z |d|z }%| dkDrV|dddd fj5|| z z}&d|z |z |&| dz zz | z }'|'dkrtEjFdy|&|'z |%d<| dkDrV|dd ddfj5||!z z}(d|z |z |(| dz zz | z })|)dkrtEjFdy|(|)z |%d<|%Scc}wcc}}w)a" 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 *shape* and *subplot_list* parameters. Also, the results could be incorrect if some subplots have ``adjustable=datalim``. Parameters ---------- shape : tuple[int, int] Number of rows and columns of the grid. span_pairs : list[tuple[slice, slice]] List of rowspans and colspans occupied by each subplot. subplot_list : list of subplots List of subplots that will be used to calculate optimal subplot_params. pad : float Padding between the figure edge and the edges of subplots, as a fraction of the font size. h_pad, w_pad : float Padding (height/width) between edges of adjacent subplots, as a fraction of the font size. Defaults to *pad*. rect : tuple (left, bottom, right, top), default: None. z font.size)sizeHNrT)originalc3>K|]}|j ywN) get_visible).0axs ^/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/matplotlib/_tight_layout.py z+_auto_adjust_subplotpars..Ls72>>##7szuTight layout not applied. The left and right margins cannot be made large enough to accommodate all Axes decorations.zuTight layout not applied. The bottom and top margins cannot be made large enough to accommodate all Axes decorations.)leftrightbottomtopznTight layout not applied. tight_layout cannot make Axes width small enough to accommodate all Axes decorationswspacezpTight layout not applied. tight_layout cannot make Axes height small enough to accommodate all Axes decorations.hspace)%rmplrcParamsget_size_in_pointslen ValueErrornpzerosrunion get_positionzipallrmartist_get_tightbbox_for_layout_only transFigureinvertedtransform_bboxstartxminstopxmaxymaxyminget_size_inchesmax _supylabel get_in_layoutget_window_extentwidth _suptitleheight _supxlabelr warn_externaldict)*figrenderershape span_pairs subplot_list ax_bbox_listpadh_padw_padrectrowscolsfont_size_inchpad_inch vpad_inch hpad_inch margin_left margin_bottom margin_right margin_top_right_topvspaceshspacessubplotsrax_bboxrowspancolspanbbtight_bbox_raw tight_bboxfig_width_inchfig_height_inchsuplabel rel_width rel_heightkwargsrh_axesvspacev_axess* r_auto_adjust_subplotparsrcs8JD$$ \\+ &((:(:(>~N &'7<<*//+II'%&*//GLL*HH& w&':??W\\+II' g%&',,*HH&!I$'*&9&9&;#NO '!Q$-++-q1H^4KK >> ..0002AA**8466;e  9x'>> >K 71b5>--/3h~6MM A**,a08O3KK ==S]]88:113BB //9;;A6  *x'?? ?J GBEN..0!4x7OO >> ..0113BB**8466.EBOO%++E$&c3PK|]}|jj ywr )rincolsrws rrz*get_tight_layout_figure..ryrzrzdtight_layout not applied: number of rows in subplot specifications must be multiples of one another.zgtight_layout not applied: number of columns in subplot specifications must be multiples of one another.)r=r>r?r@rArBrCrrr rr)r=r>r?r@rArBrCrD)r#rkpoprr9listvaluesr"r1ri get_geometrydivmodslicerUr*r,rVrc)r;rlrnr<rArBrCrDrxss_to_subplotsrr?r@ max_nrows max_ncolsr>rErFdiv_rowmod_rowdiv_colmod_colr_rrrrs rget_tight_layout_figurers@(88b"f8N8i!12&Br!!"%&$%  ; <  --/0L3ABRBOOC(BLBEnEEIEnEEIJK__&335 d!)T2!)T2 a<    ; <I a<    ; <I "**""W,bjjoo.G H "**""W,bjjoo.G HJ K)K0&c8-6 ,B1;3?3?*-U% IF F.$( feS   F6N "D   fX& &F   a&/) *E ? Au % &C)#x1:I0F5?7C7C.1e04feS/I K MW9Cs H4H9)NHzG?NNNr )rNNN)__doc__numpyr matplotlibrrrr%matplotlib.font_managerrmatplotlib.transformsrrcrrrrsrrs< .2& CGIXFDHkrs