
    \cgU                         d Z ddlZddlZddlZddlmZ ddlmZ ddl	m
Z ddlmZ  G d d      Z G d	 d
e      Z G d de      Zd Z G d de      Z G d de      Zd Z	 ddZy)zJ
Helper classes to adjust the positions of multiple axes at drawing time.
    N)_api)SubplotSpec   )	axes_sizec                       e Zd ZdZ	 ddZd Zd Zd Zd Zd Z	d	 Z
d
 Zd Zd Zd Zd ZddZd Zd Zd Zd Zed        Zed        ZddZd Zd ZddZy)DivideraQ  
    An Axes positioning class.

    The divider is initialized with lists of horizontal and vertical sizes
    (:mod:`mpl_toolkits.axes_grid1.axes_size`) based on which a given
    rectangular area will be divided.

    The `new_locator` method then creates a callable object
    that can be used as the *axes_locator* of the axes.
    Nc                     || _         || _        || _        || _        || _        | j                  |       || _        d| _        d| _        d| _	        y)a  
        Parameters
        ----------
        fig : Figure
        pos : tuple of 4 floats
            Position of the rectangle that will be divided.
        horizontal : list of :mod:`~mpl_toolkits.axes_grid1.axes_size`
            Sizes for horizontal division.
        vertical : list of :mod:`~mpl_toolkits.axes_grid1.axes_size`
            Sizes for vertical division.
        aspect : bool, optional
            Whether overall rectangular area is reduced so that the relative
            part of the horizontal and vertical scales have the same scale.
        anchor : (float, float) or {'C', 'SW', 'S', 'SE', 'E', 'NE', 'N', 'NW', 'W'}, default: 'C'
            Placement of the reduced rectangle, when *aspect* is True.
        r   N)
_fig_pos_horizontal	_vertical_anchor
set_anchor_aspect
_xrefindex
_yrefindex_locator)selffigpos
horizontalverticalaspectanchors          _/var/www/html/bid-api/venv/lib/python3.12/site-packages/mpl_toolkits/axes_grid1/axes_divider.py__init__zDivider.__init__   sP    ( 		%!    c                     t        j                  | j                         D cg c]  }|j                  |       c}      S c c}w N)nparrayget_horizontalget_sizer   rendererss      r   get_horizontal_sizeszDivider.get_horizontal_sizes;   s7    xxt7J7J7LM7L!H-7LMNNM   Ac                     t        j                  | j                         D cg c]  }|j                  |       c}      S c c}w r   )r    r!   get_verticalr#   r$   s      r   get_vertical_sizeszDivider.get_vertical_sizes>   s7    xxt7H7H7JK7J!H-7JKLLKr(   c                     || _         y)z
        Set the position of the rectangle.

        Parameters
        ----------
        pos : tuple of 4 floats
            position of the rectangle that will be divided
        Nr   )r   r   s     r   set_positionzDivider.set_positionA   s     	r   c                     | j                   S )z%Return the position of the rectangle.r-   r   s    r   get_positionzDivider.get_positionL   s    yyr   c                     t        |t              r7t        j                  t        j
                  j                  |       || _        yt        |t        t        f      rt        |      dk7  rt        d      || _        y)a  
        Parameters
        ----------
        anchor : (float, float) or {'C', 'SW', 'S', 'SE', 'E', 'NE', 'N', 'NW', 'W'}
            Either an (*x*, *y*) pair of relative coordinates (0 is left or
            bottom, 1 is right or top), 'C' (center), or a cardinal direction
            ('SW', southwest, is bottom left, etc.).

        See Also
        --------
        .Axes.set_anchor
        )r      zanchor must be str or 2-tupleN)
isinstancestrr   check_in_listmtransformsBboxcoefstuplelistlen	TypeErrorr   )r   r   s     r   r   zDivider.set_anchorP   sa     fc"{//55fE  FUDM2c&kQ6F;<<r   c                     | j                   S )zReturn the anchor.)r   r0   s    r   
get_anchorzDivider.get_anchord       ||r   c                      y r    r0   s    r   get_subplotspeczDivider.get_subplotspech   s    r   c                     || _         y)z
        Parameters
        ----------
        h : list of :mod:`~mpl_toolkits.axes_grid1.axes_size`
            sizes for horizontal division
        Nr   )r   hs     r   set_horizontalzDivider.set_horizontalk   s     r   c                     | j                   S )zReturn horizontal sizes.rE   r0   s    r   r"   zDivider.get_horizontalt   s    r   c                     || _         y)z
        Parameters
        ----------
        v : list of :mod:`~mpl_toolkits.axes_grid1.axes_size`
            sizes for vertical division
        Nr   )r   vs     r   set_verticalzDivider.set_verticalx   s     r   c                     | j                   S )zReturn vertical sizes.rJ   r0   s    r   r*   zDivider.get_vertical   s    ~~r   c                     || _         y)zE
        Parameters
        ----------
        aspect : bool
        Nr   r   r   s     r   
set_aspectzDivider.set_aspect   s     r   c                     | j                   S )zReturn aspect.rO   r0   s    r   
get_aspectzDivider.get_aspect   r@   r   c                     || _         y r   r   )r   r   s     r   set_locatorzDivider.set_locator   s	     r   c                     | j                   S r   rU   r0   s    r   get_locatorzDivider.get_locator   s    }}r   c                 r    | j                   | j                         S | j                  ||      j                  S r   )r   r1   bounds)r   axr%   s      r   get_position_runtimezDivider.get_position_runtime   s2    == $$&&==X.555r   c                 B    | j                  d      \  }}|r||z
  |z  S dS )Nr   )sum)sizestotalrel_sumabs_sums       r   _calc_kzDivider._calc_k   s,     !99Q<.57*<1<r   c                 <    t        j                  dg| |dgz        S )Nr   r   )r    cumsum)r_   ks     r   _calc_offsetszDivider._calc_offsets   s#     yy!/u1v~/00r   c                     ||dz   }||dz   }| j                   }| j                  }t        j                  | j                  ||z
  ||z
  ||z
  ||z
        }| j
                  |_        |S )a  
        Return an axes locator callable for the specified cell.

        Parameters
        ----------
        nx, nx1 : int
            Integers specifying the column-position of the
            cell. When *nx1* is None, a single *nx*-th column is
            specified. Otherwise, location of columns spanning between *nx*
            to *nx1* (but excluding *nx1*-th column) is specified.
        ny, ny1 : int
            Same as *nx* and *nx1*, but for row positions.
        r   )r   r   	functoolspartial_locaterC   )r   nxnynx1ny1xrefyreflocators           r   new_locatorzDivider.new_locator   sw     ;q&C;q&C ##LL"t)R$Yd
C$JH"&"6"6r   c                 X   || j                   z  }|| j                   z  }|| j                  z  }|| j                  z  }| j                  j                  j                  | j                  j
                  z  \  }}| j                  ||      \  }	}
}}| j                  |      }| j                  |      }| j                  |||z        }| j                  |||z        }| j                         rt        ||      }| j                  ||      }| j                  ||      }|d   |d   z
  |z  }|d   |d   z
  |z  }t        j                  j                  |	|
||      }t        j                  j                  |	|
||      }|j!                  | j#                         |      j$                  \  }}n(| j                  ||      }| j                  ||      }|	|
}}|d}|d}|||   |z  z   ||   ||   z
  |z  }}|||   |z  z   ||   ||   z
  |z  }}t        j                  j                  ||||      S )a  
        Implementation of ``divider.new_locator().__call__``.

        The axes locator callable returned by ``new_locator()`` is created as
        a `functools.partial` of this method with *nx*, *ny*, *nx1*, and *ny1*
        specifying the requested cell.
        r   )r   r   r
   bboxsizedpir\   r'   r+   rc   rS   minrg   r7   r8   from_boundsanchoredr?   p0)r   rl   rm   rn   ro   axesr%   fig_wfig_hxywrF   hsizesvsizesk_hk_vrf   oxoywwhhpbpb1x0y0x1w1y1h1s                                 r   rk   zDivider._locate   s0    	doot
dootyy~~**TYY]]:u..tX>
1a**84((2ll6519-ll6519-??CA##FA.B##FA.BR&2a5.E)BR&2a5.E)B!!--aAq9B""..q!R<C\\$//"3R8;;FB ##FC0B##FC0BB;C;Cbfun$r#wB'75&@Bbfun$r#wB'75&@B++BB;;r   c                    t        j                  g d|       |dk(  r2| j                  j                  d|       | xj                  dz  c_        y |dk(  r| j                  j                  |       y |dk(  r2| j                  j                  d|       | xj                  dz  c_        y | j                  j                  |       y )Nleftrightbottomtoppositionr   r   r   r   r   )r   r6   r   insertr   appendr   r   )r   r   rw   s      r   append_sizezDivider.append_size   s    =$,	.v##At,OOq O ##D)!NN!!!T*OOq ONN!!$'r   c                 p    |g d}|D ]+  }| j                  |t        j                  ||      |z          - y)a5  
        Add auto-adjustable padding around *use_axes* to take their decorations
        (title, labels, ticks, ticklabels) into account during layout.

        Parameters
        ----------
        use_axes : `~matplotlib.axes.Axes` or list of `~matplotlib.axes.Axes`
            The Axes whose decorations are taken into account.
        pad : float, default: 0.1
            Additional padding in inches.
        adjust_dirs : list of {"left", "right", "bottom", "top"}, optional
            The sides where padding is added; defaults to all four sides.
        Nr   )r   Size_AxesDecorationsSize)r   use_axespadadjust_dirsds        r   add_auto_adjustable_areaz Divider.add_auto_adjustable_area  s;     <KAQ 9 9(A F LM r   )NC)FNN)皙?N)__name__
__module____qualname____doc__r   r'   r+   r.   r1   r   r?   rC   rG   r"   rL   r*   rQ   rS   rV   rX   r\   staticmethodrc   rg   rs   rk   r   r   rB   r   r   r   r      s    	 &)>OM	( !6 = = 1 1
@-<^(Nr   r   c                   @     e Zd ZdZddddd fd
Zd Zd Zd Z xZS )	SubplotDividerzT
    The Divider class whose rectangle area is specified as a subplot geometry.
    Nr   r   r   r   r   c                    || _         t        | 	  |g d|xs g |xs g ||       | j                  t	        j
                  ||             y)a  
        Parameters
        ----------
        fig : `~matplotlib.figure.Figure`

        *args : tuple (*nrows*, *ncols*, *index*) or int
            The array of subplots in the figure has dimensions ``(nrows,
            ncols)``, and *index* is the index of the subplot being created.
            *index* starts at 1 in the upper left corner and increases to the
            right.

            If *nrows*, *ncols*, and *index* are all single digit numbers, then
            *args* can be passed as a single 3-digit number (e.g. 234 for
            (2, 3, 4)).
        horizontal : list of :mod:`~mpl_toolkits.axes_grid1.axes_size`, optional
            Sizes for horizontal division.
        vertical : list of :mod:`~mpl_toolkits.axes_grid1.axes_size`, optional
            Sizes for vertical division.
        aspect : bool, optional
            Whether overall rectangular area is reduced so that the relative
            part of the horizontal and vertical scales have the same scale.
        anchor : (float, float) or {'C', 'SW', 'S', 'SE', 'E', 'NE', 'N', 'NW', 'W'}, default: 'C'
            Placement of the reduced rectangle, when *aspect* is True.
        )r   r   r   r   r   N)figuresuperr   set_subplotspecr   _from_subplot_args)r   r   r   r   r   r   args	__class__s          r   r   zSubplotDivider.__init__   sR    6 l$.$4"x~2 &v 	 	7 	[;;CFGr   c                 h    | j                         j                  | j                        j                  S )z%Return the bounds of the subplot box.)rC   r1   r   rZ   r0   s    r   r1   zSubplotDivider.get_positionA  s&    ##%224;;?FFFr   c                     | j                   S )zGet the SubplotSpec instance.)_subplotspecr0   s    r   rC   zSubplotDivider.get_subplotspecE  s       r   c                 f    || _         | j                  |j                  | j                               y)zSet the SubplotSpec instance.N)r   r.   r1   r   )r   subplotspecs     r   r   zSubplotDivider.set_subplotspecI  s'    '+224;;?@r   )	r   r   r   r   r   r1   rC   r   __classcell__r   s   @r   r   r     s,     /3TSHBG!Ar   r   c                   f     e Zd ZdZd fd	ZdddZddZddZddddZd	 Z	d
 Z
d Zd Z xZS )AxesDividerz0
    Divider based on the preexisting axes.
    Nc                    || _         |t        j                  |      | _        n|| _        |t        j                  |      | _        n|| _        t        |   |j                         d| j                  g| j
                  gdd       y)zw
        Parameters
        ----------
        axes : :class:`~matplotlib.axes.Axes`
        xref
        yref
        Nr   )r   r   r   r   r   r   )	_axesr   AxesX_xrefAxesY_yrefr   r   
get_figure)r   r}   rp   rq   r   s       r   r   zAxesDivider.__init__T  sw     
<D)DJDJ<D)DJDJT__.D%)ZZLDJJ< $S 	 	2r   )
axes_classc                    | j                   }|t        |      } ||j                         |j                  d      fi |S NT)original)r   typer   r1   )r   r   kwargsr}   s       r   _get_new_axeszAxesDivider._get_new_axesj  sH    zzdJ$//+T->->->-M $"$ 	$r   c                 B   | t         j                  d   | j                  z  }|rdnd}|rMt        |t        j
                        s!t	        j                  || j                        }| j                  ||       t        |t        j
                        s!t	        j                  || j                        }| j                  ||       | j                  |rdnt        | j                        dz
  | j                        } | j                  di |}|j                  |       |S )	z
        Helper method for ``append_axes("left")`` and ``append_axes("right")``.

        See the documentation of `append_axes` for more details.

        :meta private:
        zfigure.subplot.wspacer   r   fraction_refr   r   rl   rm   rB   )mplrcParamsr   r4   r   _Basefrom_anyr   rs   r<   r   r   r   set_axes_locatorr   rw   r   
pack_startr   r   rr   r[   s           r   new_horizontalzAxesDivider.new_horizontalq  s     ;,,67$**DC"fc4::.mmCdjjAS#&$

+==DJJ?Dd#""qC(8(8$9A$= #    T)&)
G$	r   c                 B   | t         j                  d   | j                  z  }|rdnd}|rMt        |t        j
                        s!t	        j                  || j                        }| j                  ||       t        |t        j
                        s!t	        j                  || j                        }| j                  ||       | j                  | j                  |rdnt        | j                        dz
        } | j                  di |}|j                  |       |S )	z
        Helper method for ``append_axes("top")`` and ``append_axes("bottom")``.

        See the documentation of `append_axes` for more details.

        :meta private:
        zfigure.subplot.hspacer   r   r   r   r   r   rB   )r   r   r   r4   r   r   r   r   rs   r   r<   r   r   r   r   s           r   new_verticalzAxesDivider.new_vertical  s     ;,,67$**DC$h%c4::.mmCdjjAS#&$

+==DJJ?Dd#""qC$7!$; # =  T)&)
G$	r   c                    t        j                  | j                  df| j                  df| j                  df| j                  dfd|      \  }} |||f||d|}| j                  j                  |       |S )am  
        Add a new axes on a given side of the main axes.

        Parameters
        ----------
        position : {"left", "right", "bottom", "top"}
            Where the new axes is positioned relative to the main axes.
        size : :mod:`~mpl_toolkits.axes_grid1.axes_size` or float or str
            The axes width or height.  float or str arguments are interpreted
            as ``axes_size.from_any(size, AxesX(<main_axes>))`` for left or
            right axes, and likewise with ``AxesY`` for bottom or top axes.
        pad : :mod:`~mpl_toolkits.axes_grid1.axes_size` or float or str
            Padding between the axes.  float or str arguments are interpreted
            as for *size*.  Defaults to :rc:`figure.subplot.wspace` times the
            main Axes width (left or right axes) or :rc:`figure.subplot.hspace`
            times the main Axes height (bottom or top axes).
        axes_class : subclass type of `~.axes.Axes`, optional
            The type of the new axes.  Defaults to the type of the main axes.
        **kwargs
            All extra keywords arguments are passed to the created axes.
        TFr   r   )r   r   )r   check_getitemr   r   r
   add_axes)	r   r   rw   r   r   r   create_axesr   r[   s	            r   append_axeszAxesDivider.append_axes  s    . #'"4"4(($/))51(($/%%u-	6

 #Z #O",OGMO		2	r   c                 t    | j                   !| j                  j                         }|dk(  ryy| j                   S )NautoFT)r   r   rS   rP   s     r   rS   zAxesDivider.get_aspect  s6    <<ZZ**,F<<r   c                     | j                   (| j                  j                  d      }|j                  S | j                   S r   )r   r   r1   rZ   )r   rv   s     r   r1   zAxesDivider.get_position  s7    99::**D*9D;;99r   c                 f    | j                   | j                  j                         S | j                   S r   )r   r   r?   r0   s    r   r?   zAxesDivider.get_anchor  s)    <<::((**<<r   c                 6    | j                   j                         S r   )r   rC   r0   s    r   rC   zAxesDivider.get_subplotspec  s    zz))++r   r   )NFr   )r   r   r   r   r   r   r   r   r   rS   r1   r?   rC   r   r   s   @r   r   r   O  sB    2, +/ $22 $  D  ,r   r   c	                    ||z  }	||z  }
t        |      }|j                  \  }}|j                  \  }}t        j                  g |d      }d|d |df<   ||dd df<   g | |	|j	                         z
  }t        j
                  j                  ||      ^ }}||
kD  r|
|z
  |z  }t        j                  dg||z  |z         }|d   |d   z
  |z  }|d   \  }}|d   |z  |z   |z  }t        j                  j                  | |||      }t        j                  j                  | |||      }|j                  ||      j                  \  }}||||fS )Nr   ru   )r<   Tr    diagr^   linalgsolvere   r7   r8   rz   r{   r|   )r   r   r   rF   summed_widthsequal_heightsr~   r   r   total_width
max_heightneq_relseq_absssm_relssm_abssABkarrayheightr   r   h0_relh0_absr   r   r   r   r   s                                r   rk   rk     s   !)KJ 	MA$GW$GW
'1AAbqb"fIAb#2#gJ2G82kGKKM12A
 iiooa+OVV
w&'1 
A56)G35	6B
R&2a5.E	!B"1%NFF
)F
V
#u	,B				%	%aAq	1B



&
&q!R
4C\\&"%((FBr2r>r   c                   *     e Zd ZdZd fd	Zd Z xZS )HBoxDividerz
    A `.SubplotDivider` for laying out axes horizontally, while ensuring that
    they have equal heights.

    Examples
    --------
    .. plot:: gallery/axes_grid1/demo_axes_hbox_divider.py
    c                 (    t         |   |d|d      S )a  
        Create an axes locator callable for the specified cell.

        Parameters
        ----------
        nx, nx1 : int
            Integers specifying the column-position of the
            cell. When *nx1* is None, a single *nx*-th column is
            specified. Otherwise, location of columns spanning between *nx*
            to *nx1* (but excluding *nx1*-th column) is specified.
        r   r   rs   )r   rl   rn   r   s      r   rs   zHBoxDivider.new_locator  s     w"2q#q11r   c                    || j                   z  }|| j                   z  }| j                  j                  j                  | j                  j                  z  \  }}| j                  ||      \  }	}
}}| j                  |      }| j                  |      }t        |	|
||||||| j                         	      \  }}}}|d}|||   |z  z   ||   ||   z
  |z  }}||}}t        j                  j                  ||||      S Nru   )r   r
   rv   rw   rx   r\   r'   r+   rk   r?   r7   r8   rz   )r   rl   rm   rn   ro   r}   r%   r~   r   r   r   r   rF   	summed_wsequal_hsr   r   r   r   r   r   r   r   s                          r   rk   zHBoxDivider._locate  s   
dootyy~~**TYY]]:u..tX>
1a--h7	**84 q!Q	8UE4??;LNBB;Cbfun$r#wB'75&@BRB++BB;;r   r   r   r   r   r   rs   rk   r   r   s   @r   r   r     s    2<r   r   c                   *     e Zd ZdZd fd	Zd Z xZS )VBoxDividerzm
    A `.SubplotDivider` for laying out axes vertically, while ensuring that
    they have equal widths.
    c                 (    t         |   d|d|      S )a  
        Create an axes locator callable for the specified cell.

        Parameters
        ----------
        ny, ny1 : int
            Integers specifying the row-position of the
            cell. When *ny1* is None, a single *ny*-th row is
            specified. Otherwise, location of rows spanning between *ny*
            to *ny1* (but excluding *ny1*-th row) is specified.
        r   r   )r   rm   ro   r   s      r   rs   zVBoxDivider.new_locator3  s     w"1b!S11r   c                    || j                   z  }|| j                   z  }| j                  j                  j                  | j                  j                  z  \  }}| j                  ||      \  }	}
}}| j                  |      }| j                  |      }t        |
|	||||||| j                         	      \  }}}}|d}||}}|||   |z  z   ||   ||   z
  |z  }}t        j                  j                  ||||      S r   )r   r
   rv   rw   rx   r\   r+   r'   rk   r?   r7   r8   rz   )r   rl   rm   rn   ro   r}   r%   r~   r   r   r   r   rF   	summed_hsequal_wsr   r   r   r   r   r   r   r   s                          r   rk   zVBoxDivider._locateA  s   
dootyy~~**TYY]]:u..tX>
1a++H5	,,X6 q!Q	8UE4??;LNBB;CRBbfun$r#wB'75&@B++BB;;r   r   r  r   s   @r   r  r  -  s    
2<r   r  c                 d    t        |       }|j                  dd      }| j                  |       |S )Nr   r   )r   rs   r   )r}   dividerrr   s      r   make_axes_locatabler  R  s4    $G!!Q1!-G'"Nr   c                 V    |g d}t        |       }|| }|j                  |||       y)aG  
    Add auto-adjustable padding around *ax* to take its decorations (title,
    labels, ticks, ticklabels) into account during layout, using
    `.Divider.add_auto_adjustable_area`.

    By default, padding is determined from the decorations of *ax*.
    Pass *use_axes* to consider the decorations of other Axes instead.
    Nr   )r   r   r   )r  r   )r[   r   r   r   r  s        r   make_axes_area_auto_adjustabler  Z  s>     8!"%G$$hC1< % >r   )Nr   N)r   ri   numpyr    
matplotlibr   r   matplotlib.gridspecr   matplotlib.transforms
transformsr7    r   r   r   r   r   rk   r   r  r  r  rB   r   r   <module>r     s}        + + HN HNV1AW 1AhN,' N,hB&<. &<R"<. "<J 15>r   