U
    \	a                     @   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)_api   )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krz
| j}W n t	k
r   t
| }Y nX dD ]}
||  | jd	d
f| | d|}|jd|
d}|| |j |j  D ]}|d qz"|j D ]}|jd q4W n t	k
r`   Y nX |	| q|r|  }|	D ]}|| q|	S )zX
    Parameters
    ----------
    pad : float
        Fraction of the axes height.
    r         r   )Zny1N)   r
   r   T)original)ZsharexZsharey)ZnxnyF)r   r   ZAxesYZAxesXZset_horizontalZset_verticalZset_axes_locatorZnew_locatorZ_axes_classAttributeErrortype
get_figureget_positionZyaxisZget_ticklabelsZxaxisZset_visibleaxisvaluesZmajor_ticklabelsappendadd_axes)axpad
axes_classr   kwargsdividerZpad_sizeZxsizeZysizeZax_rgbr   ax1locatortr   Zfig r    D/tmp/pip-unpacked-wheel-wjyw_3jo/mpl_toolkits/axes_grid1/axes_rgb.pymake_rgb_axes   sF    	
 
r"   zax.imshow(np.dstack([r, g, b])))alternativec                 K   s   | j t|||gf|S )N)imshownpdstack)r   rgbr   r    r    r!   
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}||| | _}|r2| | n||d< t|f||d|\| _| _| _| j| j| j| jfD ]0}|j	dd j
d |j	dd jd qpd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   r"   RGBr   lineZ	set_colorZmajor_ticksZset_markeredgecolor)selfr   r   argsr   r   r   r   r    r    r!   __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)r/   r   r   r0   r1   r2   )r4   r    r    r!   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|}	| jj|f|}
| jj|f|}| j	j|f|}|	|
||fS )a  
        Create the four images {rgb, r, g, b}.

        Parameters
        ----------
        r, g, b : array-like
            The red, green, and blue arrays.
        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&   Z
zeros_liker/   r$   r0   r1   r2   )r4   r'   r(   r)   r   r/   r0   r1   r2   Zim_rgbZim_rZim_gZim_br    r    r!   r*      s     


zRGBAxes.imshow_rgbN)__name__
__module____qualname____doc__r   r.   r   delete_parameterr6   
deprecatedr7   r*   r    r    r    r!   r+   @   s   

r+   c                   @   s   e Zd ZdS )RGBAxesBaseN)r:   r;   r<   r    r    r    r!   r@      s   r@   )r	   NT)Znumpyr%   Z
matplotlibr   Zaxes_dividerr   r   Zmpl_axesr   r>   r"   r?   r*   r+   r@   r    r    r    r!   <module>   s   
2
f