o
    l’×in  ã                   @   s@   d dl ZddlmZmZ ddlmZ d
dd„ZG dd	„ d	ƒZdS )é    Né   )Úmake_axes_locatableÚSize)ÚAxesç{®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© r1   ú^/home/ubuntu/SoloSpeech/.venv/lib/python3.10/site-packages/mpl_toolkits/axes_grid1/axes_rgb.pyÚmake_rgb_axes   s@   ÿÿ
ÿÿr3   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 ]}|j	dd… j
 d¡ |j	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&   NÚw)ÚpopÚ_defaultAxesClassÚRGBr   r#   r3   ÚRÚGÚBr   ÚlineÚ	set_colorÚmajor_ticksÚset_markeredgecolor)Úselfr%   Úargsr'   r&   r$   r-   r1   r1   r2   Ú__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_liker8   Úimshowr9   r:   r;   )r@   ÚrÚgÚbr'   r8   r9   r:   r;   Úim_rgbÚim_rÚim_gÚim_br1   r1   r2   Ú
imshow_rgbr   s    ÿ


zRGBAxes.imshow_rgbN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r7   rB   rP   r1   r1   r1   r2   r4   <   s
    r4   )r   N)	ÚnumpyrE   Úaxes_dividerr   r   Úmpl_axesr   r3   r4   r1   r1   r1   r2   Ú<module>   s
    
5