rL i ,dZddlmZmZmZddZddZy)zE Helper module for the *bbox_inches* parameter in `.Figure.savefig`. )BboxTransformedBboxAffine2DNc jjjj ggt j D]}|j }||j||dj||jdj}|j|fdd|jvrj|jnjd d|_ fd}| j}tj|}|jz }t!j"ddg|j$_|j'|j(\} } jj$|z\} } t!j"| | | | j_jj+t-j|_j.j1| | z | | z jj2| z jj4| z |S) aO Temporarily adjust the figure so that only the specified area (bbox_inches) is saved. It modifies fig.bbox, fig.bbox_inches, fig.transFigure._boxout, and fig.patch. While the figure size changes, the scale of the original figure is conserved. A function which restores the original values are returned. NF)originalc|SN)ar_poss \/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/matplotlib/_tight_bbox.pyzadjust_bbox..s4 apply_aspectcyr r )poss rrzadjust_bbox..%src2tjD]%\}}}|j|| ur|`||_'__j _j jjjddddy)Nr) zipaxesset_axes_locatorrbbox bbox_inches transFigure_boxout invalidatepatch set_bounds) axlocaspectrfig locator_list old_aspectorigBboxorigBboxInchessentinels r restore_bboxz!adjust_bbox..restore_bbox's"388\:F )OBV    $!O"(  )(") ""$ Q1a(rrr )rrrrobjectrget_axes_locatorrappend get_positionfrozenr__dict__dpirscaler from_boundssize transformp0rrrrwidthheight)r#r fixed_dpir locator current_posr)tr dpi_scalex0y0w1h1rr$r%r&r'r(s` @@@@@@r adjust_bboxrAsxxH__Noo%%GJLxHhh 0%%'   OOGB- .G$oouo5<<>  k?@ R[[ (   boo .   h '/ 0 ) )GG   ) $BCGG#I&&q!?k.>.>?CO \\+.. )FB XX]]Y &FB"..sRCR@COOOO s3CHIIb"r'",chhoo.BD rc<|\}}|t|||}||fS)z A function that needs to be called when figure dpi changes during the drawing (e.g., rasterizing). It recovers the bbox and re-adjust it with the new dpi. )rA)r#bbox_inches_restorer8rr)r s rprocess_figure_for_rasterizingrDIs+!4KNCi0A >rr )__doc__matplotlib.transformsrrrrArDr rrrGsBA>B r