o
    i0                     @   s   d dl Zd dlmZ ddlmZmZ ddlmZ e	dddd
dZ
ejddddd ZG dd dZejdddG dd deZdS )    N)cbook   )make_axes_locatableSize)Axes3.3add_all{Gz?Tc              	   K   s  t | }|t|  }dd|  d t|  }dd|  d t|  }|t| ||g ||||||g | |jdddd g }	|du r^z| j}W n t	y]   t
| }Y nw dD ]Q}
||  | jd	d
f| | d|}|jd|
d}|| |j |j  D ]}|d qz|j D ]}|jd qW n	 t	y   Y nw |	| q`|r|  }|	D ]}|| q|	S )zX
    Parameters
    ----------
    pad : float
        Fraction of the axes height.
    r         r   )ny1N)   r
   r   T)original)sharexsharey)nxnyF)r   r   AxesYAxesXset_horizontalset_verticalset_axes_locatornew_locator_axes_classAttributeErrortype
get_figureget_positionyaxisget_ticklabelsxaxisset_visibleaxisvaluesmajor_ticklabelsappendadd_axes)axpad
axes_classr   kwargsdividerpad_sizexsizeysizeax_rgbr   ax1locatortr#   fig r5   [/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/mpl_toolkits/axes_grid1/axes_rgb.pymake_rgb_axes   sJ   	

r7   zax.imshow(np.dstack([r, g, b])))alternativec                 K   s   | j t|||gfi |S )N)imshownpdstack)r(   rgbr+   r5   r5   r6   
imshow_rgb;   s   r?   c                   @   sJ   e Zd ZdZeZedddddddZe	dd	d
 Z
dd ZdS )RGBAxesa  
    4-panel imshow (RGB, R, G, B).

    Layout:
    +---------------+-----+
    |               |  R  |
    +               +-----+
    |      RGB      |  G  |
    +               +-----+
    |               |  B  |
    +---------------+-----+

    Subclasses can override the ``_defaultAxesClass`` attribute.

    Attributes
    ----------
    RGB : ``_defaultAxesClass``
        The axes object for the three-channel imshow.
    R : ``_defaultAxesClass``
        The axes object for the red channel imshow.
    G : ``_defaultAxesClass``
        The axes object for the green channel imshow.
    B : ``_defaultAxesClass``
        The axes object for the blue channel imshow.
    r   r   r   T)r)   r   c                O   s   | d| j}||i | | _}|r| | n||d< t|f||d|\| _| _| _| j| j| j| jfD ]}|j	dd j
d |j	dd jd q:dS )a  
        Parameters
        ----------
        pad : float, default: 0
            fraction of the axes height to put as padding.
        add_all : bool, default: True
            Whether to add the {rgb, r, g, b} axes to the figure.
            This parameter is deprecated.
        axes_class : matplotlib.axes.Axes

        *args
            Unpacked into axes_class() init for RGB
        **kwargs
            Unpacked into axes_class() init for RGB, R, G, B axes
        r*   r   )r)   r*   Nw)pop_defaultAxesClassRGBr   r'   r7   RGBr#   line	set_colormajor_ticksset_markeredgecolor)selfr)   r   argsr+   r*   r(   r1   r5   r5   r6   __init__]   s    zRGBAxes.__init__c                 C   s:   | j  | j | j  | j | j  | j dS )z@Add red, green and blue axes to the RGB composite's axes figure.N)rD   r   r'   rE   rF   rG   )rL   r5   r5   r6   add_RGB_to_figure{   s   zRGBAxes.add_RGB_to_figurec                 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 : array-like
            The red array
        g : array-like
            The green array
        b : array-like
            The blue array
        kwargs : imshow kwargs
            kwargs get unpacked into the 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
ValueErrorr:   r;   
zeros_likerD   r9   rE   rF   rG   )rL   r<   r=   r>   r+   rD   rE   rF   rG   im_rgbim_rim_gim_br5   r5   r6   r?      s    


zRGBAxes.imshow_rgbN)__name__
__module____qualname____doc__r   rC   r   _delete_parameterrN   
deprecatedrO   r?   r5   r5   r5   r6   r@   @   s    

r@   c                   @   s   e Zd ZdS )RGBAxesBaseN)rW   rX   rY   r5   r5   r5   r6   r]      s    r]   )r	   NT)numpyr:   
matplotlibr   axes_dividerr   r   mpl_axesr   r[   r7   r\   r?   r@   r]   r5   r5   r5   r6   <module>   s    
2
i