a
    ëÝEb0T  ã                   @   sæ  d Z ddlZddlZddlZddlmZ ddlZddlmZm	Z	 ddl
mZmZmZmZmZmZmZmZmZmZ ddlmZmZ G dd„ dƒZG d	d
„ d
eƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZ G dd„ deƒZ!G dd„ deƒZ"G dd„ deƒZ#G dd „ d eƒZ$G d!d"„ d"eƒZ%eee"e%eed#œZ&d$d%„ Z'd&d'„ Z(e(j �r¦e(j d(d) )e*e+e'ƒ ƒ¡i e(_ d*d+„ Z,d,d-„ Z-e	j.j/d.d) )d/d0„ e'ƒ D ƒ¡ e-ƒ  0¡ d1� dS )2aÜ  
Scales define the distribution of data values on an axis, e.g. a log scaling.
They are defined as subclasses of `ScaleBase`.

See also `.axes.Axes.set_xscale` and the scales examples in the documentation.

See :doc:`/gallery/scales/custom_scale` for a full example of defining a custom
scale.

Matplotlib also supports non-separable transformations that operate on both
`~.axis.Axis` at the same time.  They are known as projections, and defined in
`matplotlib.projections`.
é    N)Úma)Ú_apiÚ	docstring)
ÚNullFormatterÚScalarFormatterÚLogFormatterSciNotationÚLogitFormatterÚNullLocatorÚ
LogLocatorÚAutoLocatorÚAutoMinorLocatorÚSymmetricalLogLocatorÚLogitLocator)Ú	TransformÚIdentityTransformc                   @   s0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )Ú	ScaleBasea  
    The base class for all scales.

    Scales are separable transformations, working on a single dimension.

    Subclasses should override

    :attr:`name`
        The scale's name.
    :meth:`get_transform`
        A method returning a `.Transform`, which converts data coordinates to
        scaled coordinates.  This transform should be invertible, so that e.g.
        mouse positions can be converted back to data coordinates.
    :meth:`set_default_locators_and_formatters`
        A method that sets default locators and formatters for an `~.axis.Axis`
        that uses this scale.
    :meth:`limit_range_for_scale`
        An optional method that "fixes" the axis range to acceptable values,
        e.g. restricting log-scaled axes to positive values.
    c                 C   s   dS )a‰  
        Construct a new scale.

        Notes
        -----
        The following note is for scale implementors.

        For back-compatibility reasons, scales take an `~matplotlib.axis.Axis`
        object as first argument.  However, this argument should not
        be used: a single scale object should be usable by multiple
        `~matplotlib.axis.Axis`\es at the same time.
        N© ©ÚselfÚaxisr   r   úP/home/ja/django-apps/lartica_env/lib/python3.9/site-packages/matplotlib/scale.pyÚ__init__4   s    zScaleBase.__init__c                 C   s
   t ƒ ‚dS )zL
        Return the `.Transform` object associated with this scale.
        N©ÚNotImplementedError©r   r   r   r   Úget_transformB   s    zScaleBase.get_transformc                 C   s
   t ƒ ‚dS )zi
        Set the locators and formatters of *axis* to instances suitable for
        this scale.
        Nr   r   r   r   r   Ú#set_default_locators_and_formattersH   s    z-ScaleBase.set_default_locators_and_formattersc                 C   s   ||fS )zú
        Return the range *vmin*, *vmax*, restricted to the
        domain supported by this scale (if any).

        *minpos* should be the minimum positive value in the data.
        This is used by log scales to determine a minimum value.
        r   ©r   ZvminZvmaxZminposr   r   r   Úlimit_range_for_scaleO   s    zScaleBase.limit_range_for_scaleN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r      s
   r   c                   @   s,   e Zd ZdZdZdd„ Zdd„ Zdd„ Zd	S )
ÚLinearScalez#
    The default linear scale.
    Úlinearc                 C   s   dS )z	
        Nr   r   r   r   r   r   a   s    zLinearScale.__init__c                 C   sj   |  tƒ ¡ | tƒ ¡ | tƒ ¡ |jdkr8tjd sL|jdkrZtjd rZ| 	t
ƒ ¡ n| 	tƒ ¡ d S ©NÚxzxtick.minor.visibleÚyzytick.minor.visible©Úset_major_locatorr   Úset_major_formatterr   Úset_minor_formatterr   Z	axis_nameÚmplZrcParamsÚset_minor_locatorr   r	   r   r   r   r   r   h   s    ÿÿz/LinearScale.set_default_locators_and_formattersc                 C   s   t ƒ S )z€
        Return the transform for linear scaling, which is just the
        `~matplotlib.transforms.IdentityTransform`.
        )r   r   r   r   r   r   t   s    zLinearScale.get_transformN)r   r    r!   r"   Únamer   r   r   r   r   r   r   r#   Z   s
   r#   c                       s8   e Zd ZdZd ZZ‡ fdd„Zdd„ Zdd„ Z‡  Z	S )	ÚFuncTransformzi
    A simple transform that takes and arbitrary function for the
    forward and inverse transform.
    é   c                    s4   t ƒ  ¡  t|ƒr(t|ƒr(|| _|| _ntdƒ‚dS )a£  
        Parameters
        ----------
        forward : callable
            The forward function for the transform.  This function must have
            an inverse and, for best behavior, be monotonic.
            It must have the signature::

               def forward(values: array-like) -> array-like

        inverse : callable
            The inverse of the forward function.  Signature as ``forward``.
        z,arguments to FuncTransform must be functionsN)Úsuperr   ÚcallableÚ_forwardÚ_inverseÚ
ValueError)r   ÚforwardÚinverse©Ú	__class__r   r   r   „   s
    
zFuncTransform.__init__c                 C   s
   |   |¡S ©N)r3   )r   Úvaluesr   r   r   Útransform_non_affine™   s    z"FuncTransform.transform_non_affinec                 C   s   t | j| jƒS r:   )r/   r4   r3   r   r   r   r   Úinvertedœ   s    zFuncTransform.inverted)
r   r    r!   r"   Ú
input_dimsÚoutput_dimsr   r<   r=   Ú__classcell__r   r   r8   r   r/   |   s
   r/   c                   @   s,   e Zd ZdZdZdd„ Zdd„ Zdd„ Zd	S )
Ú	FuncScalezN
    Provide an arbitrary scale with user-supplied function for the axis.
    Úfunctionc                 C   s   |\}}t ||ƒ}|| _dS )a•  
        Parameters
        ----------
        axis : `~matplotlib.axis.Axis`
            The axis for the scale.
        functions : (callable, callable)
            two-tuple of the forward and inverse functions for the scale.
            The forward function must be monotonic.

            Both functions must have the signature::

               def forward(values: array-like) -> array-like
        N)r/   Ú
_transform)r   r   Ú	functionsr6   r7   Ú	transformr   r   r   r   §   s    
zFuncScale.__init__c                 C   s   | j S )z7Return the `.FuncTransform` associated with this scale.©rC   r   r   r   r   r   ¹   s    zFuncScale.get_transformc                 C   sj   |  tƒ ¡ | tƒ ¡ | tƒ ¡ |jdkr8tjd sL|jdkrZtjd rZ| 	t
ƒ ¡ n| 	tƒ ¡ d S r%   r(   r   r   r   r   r   ½   s    ÿÿz-FuncScale.set_default_locators_and_formattersN)r   r    r!   r"   r.   r   r   r   r   r   r   r   rA       s
   rA   c                       s>   e Zd Zd ZZd‡ fdd„	Zdd„ Zdd„ Zd	d
„ Z‡  Z	S )ÚLogTransformr0   Úclipc                    sB   t ƒ  ¡  |dks|dkr"tdƒ‚|| _tjdddœ|d�| _d S )Nr   r0   z#The log base cannot be <= 0 or == 1TF©rH   Úmask©Únonpositive)r1   r   r5   Úbaser   Úcheck_getitemÚ_clip)r   rM   rL   r8   r   r   r   Í   s    

ÿzLogTransform.__init__c                 C   s    d  t| ƒj| j| jrdnd¡S )Nz{}(base={}, nonpositive={!r})rH   rJ   )ÚformatÚtyper   rM   rO   r   r   r   r   Ú__str__Õ   s    ÿzLogTransform.__str__c                 C   sŒ   t jddd��j t jt jdt jdt ji | j¡}|r>||ƒ}nt  |¡}|t  | j¡ }| jrjd||dk< W d   ƒ n1 s~0    Y  |S )NÚignore©ÚdivideÚinvalidé   é
   éüÿÿr   )	ÚnpÚerrstateÚeÚlogÚlog2Úlog10ÚgetrM   rO   )r   Úar]   Úoutr   r   r   r<   Ù   s     


*z!LogTransform.transform_non_affinec                 C   s
   t | jƒS r:   )ÚInvertedLogTransformrM   r   r   r   r   r=   ï   s    zLogTransform.inverted)rH   ©
r   r    r!   r>   r?   r   rR   r<   r=   r@   r   r   r8   r   rG   Ê   s
   rG   c                       s<   e Zd Zd ZZ‡ fdd„Zdd„ Zdd„ Zdd	„ Z‡  Z	S )
rc   r0   c                    s   t ƒ  ¡  || _d S r:   )r1   r   rM   )r   rM   r8   r   r   r   ö   s    
zInvertedLogTransform.__init__c                 C   s   d  t| ƒj| j¡S )Nz{}(base={}))rP   rQ   r   rM   r   r   r   r   rR   ú   s    zInvertedLogTransform.__str__c                 C   s   t  | j|¡S r:   )r   ÚpowerrM   ©r   ra   r   r   r   r<   ý   s    z)InvertedLogTransform.transform_non_affinec                 C   s
   t | jƒS r:   )rG   rM   r   r   r   r   r=      s    zInvertedLogTransform.invertedrd   r   r   r8   r   rc   ó   s
   rc   c                   @   sJ   e Zd ZdZdZddddœdd„Zed	d
„ ƒZdd„ Zdd„ Z	dd„ Z
dS )ÚLogScalezT
    A standard logarithmic scale.  Care is taken to only plot positive values.
    r]   rX   NrH   )rM   ÚsubsrL   c                C   s   t ||ƒ| _|| _dS )a£  
        Parameters
        ----------
        axis : `~matplotlib.axis.Axis`
            The axis for the scale.
        base : float, default: 10
            The base of the logarithm.
        nonpositive : {'clip', 'mask'}, default: 'clip'
            Determines the behavior for non-positive values. They can either
            be masked as invalid, or clipped to a very small positive number.
        subs : sequence of int, default: None
            Where to place the subticks between each major tick.  For example,
            in a log10 scale, ``[2, 3, 4, 5, 6, 7, 8, 9]`` will place 8
            logarithmically spaced minor ticks between each major tick.
        N)rG   rC   rh   )r   r   rM   rh   rL   r   r   r   r   
  s    zLogScale.__init__c                 C   s   | j jS r:   ©rC   rM   r   r   r   r   Ú<lambda>  ó    zLogScale.<lambda>c                 C   sR   |  t| jƒ¡ | t| jƒ¡ | t| j| jƒ¡ | t| j| jd ud�¡ d S )N)ZlabelOnlyBase)r)   r
   rM   r*   r   r-   rh   r+   r   r   r   r   r     s    ÿÿz,LogScale.set_default_locators_and_formattersc                 C   s   | j S )z6Return the `.LogTransform` associated with this scale.rF   r   r   r   r   r   (  s    zLogScale.get_transformc                 C   s.   t  |¡sd}|dkr|n||dkr(|n|fS )z$Limit the domain to positive values.gYóøÂn¥r   ©rZ   Úisfiniter   r   r   r   r   ,  s
    
ÿzLogScale.limit_range_for_scale)r   r    r!   r"   r.   r   ÚpropertyrM   r   r   r   r   r   r   r   rg     s   	rg   c                   @   s2   e Zd ZdZdZddd„Zedd„ ƒZdd	„ Zd
S )ÚFuncScaleLogzu
    Provide an arbitrary scale with user-supplied function for the axis and
    then put on a logarithmic axes.
    ÚfunctionlogrX   c                 C   s&   |\}}d| _ t||ƒt|ƒ | _dS )aã  
        Parameters
        ----------
        axis : `matplotlib.axis.Axis`
            The axis for the scale.
        functions : (callable, callable)
            two-tuple of the forward and inverse functions for the scale.
            The forward function must be monotonic.

            Both functions must have the signature::

                def forward(values: array-like) -> array-like

        base : float, default: 10
            Logarithmic base of the scale.
        N)rh   r/   rG   rC   )r   r   rD   rM   r6   r7   r   r   r   r   =  s    zFuncScaleLog.__init__c                 C   s
   | j jjS r:   )rC   Ú_brM   r   r   r   r   rM   R  s    zFuncScaleLog.basec                 C   s   | j S )z3Return the `.Transform` associated with this scale.rF   r   r   r   r   r   V  s    zFuncScaleLog.get_transformN)rX   )	r   r    r!   r"   r.   r   rn   rM   r   r   r   r   r   ro   5  s   

ro   c                       s4   e Zd Zd ZZ‡ fdd„Zdd„ Zdd„ Z‡  ZS )ÚSymmetricalLogTransformr0   c                    sp   t ƒ  ¡  |dkrtdƒ‚|dkr*tdƒ‚|dkr:tdƒ‚|| _|| _|| _|d| jd   | _t |¡| _	d S )Nç      ð?z'base' must be larger than 1g        z'linthresh' must be positivez'linscale' must be positiveéÿÿÿÿ)
r1   r   r5   rM   Ú	linthreshÚlinscaleÚ_linscale_adjrZ   r]   Ú	_log_base)r   rM   ru   rv   r8   r   r   r   ^  s    
z SymmetricalLogTransform.__init__c                 C   s„   t  |¡}t jddd��F t  |¡| j | jt  || j ¡| j   }|| jk}W d   ƒ n1 sd0    Y  || | j ||< |S ©NrS   rT   )rZ   Úabsr[   Úsignru   rw   r]   rx   ©r   ra   Zabs_arb   Zinsider   r   r   r<   l  s    
ÿÿ(z,SymmetricalLogTransform.transform_non_affinec                 C   s   t | j| j| jƒS r:   )ÚInvertedSymmetricalLogTransformrM   ru   rv   r   r   r   r   r=   v  s    
ÿz SymmetricalLogTransform.inverted©	r   r    r!   r>   r?   r   r<   r=   r@   r   r   r8   r   rr   [  s   
rr   c                       s4   e Zd Zd ZZ‡ fdd„Zdd„ Zdd„ Z‡  ZS )r}   r0   c                    sL   t ƒ  ¡  t|||ƒ}|| _|| _| |¡| _|| _|d| jd   | _d S )Nrs   rt   )	r1   r   rr   rM   ru   rE   Úinvlinthreshrv   rw   )r   rM   ru   rv   Úsymlogr8   r   r   r   ~  s    
z(InvertedSymmetricalLogTransform.__init__c                 C   s‚   t  |¡}t jddd��D t  |¡| j t  | j|| j | j ¡ }|| jk}W d   ƒ n1 sb0    Y  || | j ||< |S ry   )	rZ   rz   r[   r{   ru   re   rM   rw   r   r|   r   r   r   r<   ‡  s    
ÿÿ(z4InvertedSymmetricalLogTransform.transform_non_affinec                 C   s   t | j| j| jƒS r:   )rr   rM   ru   rv   r   r   r   r   r=   ‘  s    ÿz(InvertedSymmetricalLogTransform.invertedr~   r   r   r8   r   r}   {  s   	
r}   c                   @   s\   e Zd ZdZdZdddddœdd	„Zed
d„ ƒZedd„ ƒZedd„ ƒZ	dd„ Z
dd„ ZdS )ÚSymmetricalLogScalea  
    The symmetrical logarithmic scale is logarithmic in both the
    positive and negative directions from the origin.

    Since the values close to zero tend toward infinity, there is a
    need to have a range around zero that is linear.  The parameter
    *linthresh* allows the user to specify the size of this range
    (-*linthresh*, *linthresh*).

    Parameters
    ----------
    base : float, default: 10
        The base of the logarithm.

    linthresh : float, default: 2
        Defines the range ``(-x, x)``, within which the plot is linear.
        This avoids having the plot go to infinity around zero.

    subs : sequence of int
        Where to place the subticks between each major tick.
        For example, in a log10 scale: ``[2, 3, 4, 5, 6, 7, 8, 9]`` will place
        8 logarithmically spaced minor ticks between each major tick.

    linscale : float, optional
        This allows the linear range ``(-linthresh, linthresh)`` to be
        stretched relative to the logarithmic range. Its value is the number of
        decades to use for each half of the linear range. For example, when
        *linscale* == 1.0 (the default), the space used for the positive and
        negative halves of the linear range will be equal to one decade in
        the logarithmic range.
    r€   rX   rW   Nr0   )rM   ru   rh   rv   c                C   s   t |||ƒ| _|| _d S r:   )rr   rC   rh   )r   r   rM   ru   rh   rv   r   r   r   r   ¸  s    zSymmetricalLogScale.__init__c                 C   s   | j jS r:   ri   r   r   r   r   rj   ¼  rk   zSymmetricalLogScale.<lambda>c                 C   s   | j jS r:   )rC   ru   r   r   r   r   rj   ½  rk   c                 C   s   | j jS r:   )rC   rv   r   r   r   r   rj   ¾  rk   c                 C   sH   |  t|  ¡ ƒ¡ | t| jƒ¡ | t|  ¡ | jƒ¡ | t	ƒ ¡ d S r:   )
r)   r   r   r*   r   rM   r-   rh   r+   r   r   r   r   r   r   À  s    ÿz7SymmetricalLogScale.set_default_locators_and_formattersc                 C   s   | j S )zAReturn the `.SymmetricalLogTransform` associated with this scale.rF   r   r   r   r   r   È  s    z!SymmetricalLogScale.get_transform)r   r    r!   r"   r.   r   rn   rM   ru   rv   r   r   r   r   r   r   r�   –  s   r�   c                       s>   e Zd Zd ZZd‡ fdd„	Zdd„ Zdd„ Zd	d
„ Z‡  Z	S )ÚLogitTransformr0   rJ   c                    s6   t ƒ  ¡  tjddg|d� || _dddœ| | _d S )NrJ   rH   rK   TFrI   )r1   r   r   Zcheck_in_listÚ_nonpositiverO   ©r   rL   r8   r   r   r   Ð  s    
zLogitTransform.__init__c                 C   sb   t jddd��" t  |d|  ¡}W d  ƒ n1 s60    Y  | jr^d||dk< d|d|k< |S )z,logit transform (base 10), masked or clippedrS   rT   r0   NrY   r   iè  )rZ   r[   r_   rO   )r   ra   rb   r   r   r   r<   Ö  s    0z#LogitTransform.transform_non_affinec                 C   s
   t | jƒS r:   )ÚLogisticTransformrƒ   r   r   r   r   r=   ß  s    zLogitTransform.invertedc                 C   s   d  t| ƒj| j¡S ©Nz{}({!r})©rP   rQ   r   rƒ   r   r   r   r   rR   â  s    zLogitTransform.__str__)rJ   ©
r   r    r!   r>   r?   r   r<   r=   rR   r@   r   r   r8   r   r‚   Í  s
   	r‚   c                       s>   e Zd Zd ZZd‡ fdd„	Zdd„ Zdd„ Zd	d
„ Z‡  Z	S )r…   r0   rJ   c                    s   t ƒ  ¡  || _d S r:   )r1   r   rƒ   r„   r8   r   r   r   é  s    
zLogisticTransform.__init__c                 C   s   ddd|    S )zlogistic transform (base 10)rs   r0   rX   r   rf   r   r   r   r<   í  s    z&LogisticTransform.transform_non_affinec                 C   s
   t | jƒS r:   )r‚   rƒ   r   r   r   r   r=   ñ  s    zLogisticTransform.invertedc                 C   s   d  t| ƒj| j¡S r†   r‡   r   r   r   r   rR   ô  s    zLogisticTransform.__str__)rJ   rˆ   r   r   r8   r   r…   æ  s
   r…   c                   @   s>   e Zd ZdZdZddddœdd„Zd	d
„ Zdd„ Zdd„ ZdS )Ú
LogitScalezÜ
    Logit scale for data between zero and one, both excluded.

    This scale is similar to a log scale close to zero and to one, and almost
    linear around 0.5. It maps the interval ]0, 1[ onto ]-infty, +infty[.
    ÚlogitrJ   z\frac{1}{2}F©Úone_halfÚuse_overlinec                C   s   t |ƒ| _|| _|| _dS )a„  
        Parameters
        ----------
        axis : `matplotlib.axis.Axis`
            Currently unused.
        nonpositive : {'mask', 'clip'}
            Determines the behavior for values beyond the open interval ]0, 1[.
            They can either be masked as invalid, or clipped to a number very
            close to 0 or 1.
        use_overline : bool, default: False
            Indicate the usage of survival notation (\overline{x}) in place of
            standard notation (1-x) for probability close to one.
        one_half : str, default: r"\frac{1}{2}"
            The string used for ticks formatter to represent 1/2.
        N)r‚   rC   Ú_use_overlineÚ	_one_half)r   r   rL   rŒ   r�   r   r   r   r     s    
zLogitScale.__init__c                 C   s   | j S )z8Return the `.LogitTransform` associated with this scale.rF   r   r   r   r   r     s    zLogitScale.get_transformc                 C   sN   |  tƒ ¡ | t| j| jd�¡ | tdd�¡ | td| j| jd�¡ d S )Nr‹   T)Úminor)r�   rŒ   r�   )r)   r   r*   r   r�   rŽ   r-   r+   r   r   r   r   r     s    þÿýÿz.LogitScale.set_default_locators_and_formattersc                 C   s2   t  |¡sd}|dkr|n||dkr,d| n|fS )zH
        Limit the domain to values between 0 and 1 (excluded).
        gH¯¼šò×z>r   r0   rl   r   r   r   r   r   -  s
    
ÿz LogitScale.limit_range_for_scaleN)rJ   )	r   r    r!   r"   r.   r   r   r   r   r   r   r   r   r‰   ø  s   ÿr‰   )r$   r]   r€   rŠ   rB   rp   c                   C   s   t tƒS )z)Return the names of the available scales.)ÚsortedÚ_scale_mappingr   r   r   r   Úget_scale_namesA  s    r“   c                 K   s@   | |   ¡ kr"tjddd� |   ¡ } tjt| d�}||fi |¤ŽS )z€
    Return a scale class by name.

    Parameters
    ----------
    scale : {%(names)s}
    axis : `matplotlib.axis.Axis`
    z3.5zjSupport for case-insensitive scales is deprecated since %(since)s and support will be removed %(removal)s.)Úmessage)Úscale)Úlowerr   Zwarn_deprecatedrN   r’   )r•   r   ÚkwargsZ	scale_clsr   r   r   Úscale_factoryF  s    	ÿr˜   Únamesz, c                 C   s   | t | j< dS )z�
    Register a new kind of scale.

    Parameters
    ----------
    scale_class : subclass of `ScaleBase`
        The scale to register.
    N)r’   r.   )Úscale_classr   r   r   Úregister_scale]  s    	r›   c               	   C   sP   g } t  ¡ D ]8\}}t |j¡p"d}|  d|›�dt |d¡dg¡ qd | ¡S )zF
    Helper function for generating docstrings related to scales.
    Ú z    z        Ú
)	r’   ÚitemsÚinspectÚgetdocr   ÚextendÚtextwrapÚindentÚjoin)Údocsr.   rš   r   r   r   r   Ú_get_scale_docsi  s    
ür¦   z{%s}c                 C   s   g | ]}t |ƒ‘qS r   )Úrepr)Ú.0r&   r   r   r   Ú
<listcomp>z  rk   r©   )Z
scale_typeZ
scale_docs)1r"   rŸ   r¢   ÚnumpyrZ   r   Z
matplotlibr,   r   r   Zmatplotlib.tickerr   r   r   r   r	   r
   r   r   r   r   Zmatplotlib.transformsr   r   r   r#   r/   rA   rG   rc   rg   ro   rr   r}   r�   r‚   r…   r‰   r’   r“   r˜   r¤   Úmapr§   r›   r¦   ZinterpdÚupdateÚrstripr   r   r   r   Ú<module>   sR   0<"$*)1& 7@ú
ÿþ