
    P/Ph
                     .    d Z ddlmZmZmZ ddZddZdS )zE
Helper module for the *bbox_inches* parameter in `.Figure.savefig`.
    )BboxTransformedBboxAffine2DNc                 T     j          j         j        j        g g t	                       j        D ]}|                                }||                     ||d                                         |           |	                    d          
                                }|                    |fd           d|j        v r                    |j                   n                               d	d|_        ψ fd}| j        }t                                          |          }| j        z  }t!          j        ddg|j        R   _        |                    |j                  \  }	}
 j         j        |z  \  }}t!          j        |	 |
 ||           j        _         j                                         t-           j        |           _          j                            |	|z  |
|z   j         j        |z   j         j        |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                     |S N )ar_poss      V/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/matplotlib/_tight_bbox.py<lambda>zadjust_bbox.<locals>.<lambda>   s    4     apply_aspectc                     d S r	   r
   )poss    r   r   zadjust_bbox.<locals>.<lambda>%   s    4 r   c                  (   t          j                  D ])\  } }}|                     |           |	u r| `"|| _        *_        _        j        _        j                                         j	        
                    dddd           d S )Nr      )zipaxesset_axes_locatorr   bboxbbox_inchestransFigure_boxout
invalidatepatch
set_bounds)
axlocaspectr   figlocator_list
old_aspectorigBboxorigBboxInchessentinels
      r   restore_bboxz!adjust_bbox.<locals>.restore_bbox'   s    "38\:FF 	) 	)OBV$$$!!OO"((")""$$$	Q1a(((((r   r   r	   )r   r   r   r   objectr   get_axes_locatorr   appendget_positionfrozenr   __dict__dpir   scaler   from_boundssize	transformp0r   r   r   r   widthheight)r#   r   	fixed_dpir    locatorcurrent_posr)   tr	dpi_scalex0y0w1h1r   r$   r%   r&   r'   r(   s   `            @@@@@@r   adjust_bboxrA      sT    xH_No%GJLxxHh 0 0%%''OOGGB--...G$$$oouo55<<>>
k???@@@R[((bo....h'''///) ) ) ) ) ) ) ) ) ) ) G				)	$	$BCG#I&q!?k.>???CO\\+.))FBX]Y&FB".sRCR@@COO   s33CHIb"r'",cho.BD D D r   c                 J    |\  }} |             t          | ||          }||fS )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_restorer8   r   r)   r   s         r   process_figure_for_rasterizingrD   I   s4     !4KLNNNCi00A>r   r	   )__doc__matplotlib.transformsr   r   r   rA   rD   r
   r   r   <module>rG      sc     B A A A A A A A A A> > > >B     r   