o
    -ñhk  ã                   @   sP   d dl mZ d dlZddlmZmZ ddlmZm	Z	 ddd„Z
G d	d
„ d
ƒZdS )é    )Ú
MethodTypeNé   )Úmake_axes_locatableÚSize)ÚAxesÚSimpleAxisArtistç{®Gáz„?c              	   K   sf  t | ƒ}|t | ¡ }dd|  d t | ¡ }dd|  d t | ¡ }| t | ¡||g¡ | |||||g¡ |  |jdddd¡ g }|du rOt| ƒ}dD ]Q}	||  	¡ | j
d	d
f| | dœ|¤Ž}
|jd|	d}|
 |¡ |
j ¡ |
j ¡  D ]}| d¡ q{z|
j ¡ D ]}|j d¡ q‰W n	 tyœ   Y nw | |
¡ qQ|  	¡ }|D ]}
| |
¡ q©|S )a¤  
    Parameters
    ----------
    ax : `~matplotlib.axes.Axes`
        Axes instance to create the RGB Axes in.
    pad : float, optional
        Fraction of the Axes height to pad.
    axes_class : `matplotlib.axes.Axes` or None, optional
        Axes class to use for the R, G, and B Axes. If None, use
        the same class as *ax*.
    **kwargs
        Forwarded to *axes_class* init for the R, G, and B Axes.
    r   é   é   r   éÿÿÿÿ)Úny1N)é   r	   r   T)Úoriginal)ÚsharexÚsharey)ÚnxÚnyF)r   r   ÚAxesYÚAxesXÚset_horizontalÚset_verticalÚset_axes_locatorÚnew_locatorÚtypeÚ
get_figureÚget_positionÚyaxisÚget_ticklabelsÚxaxisÚset_visibleÚaxisÚvaluesÚmajor_ticklabelsÚAttributeErrorÚappendÚadd_axes)ÚaxÚpadÚ
axes_classÚkwargsÚdividerÚpad_sizeÚxsizeÚysizeÚax_rgbr   Úax1ÚlocatorÚtr    Úfig© r3   úT/var/www/vscode/kcb/lib/python3.10/site-packages/mpl_toolkits/axes_grid1/axes_rgb.pyÚmake_rgb_axes	   s@   ÿÿ
ÿÿr5   c                   @   s*   e Zd ZdZeZddœdd„Zdd„ ZdS )	ÚRGBAxesu°  
    4-panel `~.Axes.imshow` (RGB, R, G, B).

    Layout::

        â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”
        â”‚               â”‚  R  â”‚
        â”‚               â”œâ”€â”€â”€â”€â”€â”¤
        â”‚      RGB      â”‚  G  â”‚
        â”‚               â”œâ”€â”€â”€â”€â”€â”¤
        â”‚               â”‚  B  â”‚
        â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜

    Subclasses can override the ``_defaultAxesClass`` attribute.
    By default RGBAxes uses `.mpl_axes.Axes`.

    Attributes
    ----------
    RGB : ``_defaultAxesClass``
        The Axes object for the three-channel `~.Axes.imshow`.
    R : ``_defaultAxesClass``
        The Axes object for the red channel `~.Axes.imshow`.
    G : ``_defaultAxesClass``
        The Axes object for the green channel `~.Axes.imshow`.
    B : ``_defaultAxesClass``
        The Axes object for the blue channel `~.Axes.imshow`.
    r   )r'   c             
   O   s  |  d| j¡}||i |¤Ž | _}| ¡  |¡ t|f||dœ|¤Ž\| _| _| _| j| j| j| jfD ]N}t	|j
tƒrjt | ¡}|jt|jd|jd ƒt|jd|jd ƒt|jd|jd ƒt|jd|jd ƒd	 n|j
}|d
d
… j d¡ |d
d
… j d¡ q3d
S )aª  
        Parameters
        ----------
        pad : float, default: 0
            Fraction of the Axes height to put as padding.
        axes_class : `~matplotlib.axes.Axes`
            Axes class to use. If not provided, ``_defaultAxesClass`` is used.
        *args
            Forwarded to *axes_class* init for the RGB Axes
        **kwargs
            Forwarded to *axes_class* init for the RGB, R, G, and B Axes
        r(   )r'   r(   r   Úbottomr	   ÚtopÚleftÚright)r7   r8   r9   r:   NÚw)ÚpopÚ_defaultAxesClassÚRGBr   r%   r5   ÚRÚGÚBÚ
isinstancer    r   r   ÚAxisDictÚupdater   r   Úspinesr   ÚlineÚ	set_colorÚmajor_ticksÚset_markeredgecolor)Úselfr'   Úargsr)   r(   r&   r/   Úadr3   r3   r4   Ú__init__]   s.   ÿÿÿ
üõzRGBAxes.__init__c                 K   s
  |j |j   kr|j ksn td|j › d|j › d|j › dƒ‚t |||g¡}t |¡}||dd…dd…df< t |¡}||dd…dd…df< t |¡}||dd…dd…df< | jj|fi |¤Ž}	| jj|fi |¤Ž}
| jj|fi |¤Ž}| j	j|fi |¤Ž}|	|
||fS )aÉ  
        Create the four images {rgb, r, g, b}.

        Parameters
        ----------
        r, g, b : array-like
            The red, green, and blue arrays.
        **kwargs
            Forwarded to `~.Axes.imshow` calls for the four images.

        Returns
        -------
        rgb : `~matplotlib.image.AxesImage`
        r : `~matplotlib.image.AxesImage`
        g : `~matplotlib.image.AxesImage`
        b : `~matplotlib.image.AxesImage`
        zInput shapes (z, z) do not matchNr   r   r	   )
ÚshapeÚ
ValueErrorÚnpÚdstackÚ
zeros_liker>   Úimshowr?   r@   rA   )rJ   ÚrÚgÚbr)   r>   r?   r@   rA   Úim_rgbÚim_rÚim_gÚim_br3   r3   r4   Ú
imshow_rgb}   s    ÿ


zRGBAxes.imshow_rgbN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r=   rM   r[   r3   r3   r3   r4   r6   >   s
     r6   )r   N)Útypesr   ÚnumpyrP   Úaxes_dividerr   r   Úmpl_axesr   r   r5   r6   r3   r3   r3   r4   Ú<module>   s    
5