ó
 m[c           @` s½   d  d l  m Z m Z m Z m Z d  d l Z d  d l Z d d l m	 Z	 m
 Z
 m Z d  d l Z d d l m Z d d e d „ Z d „  Z d	 e f d
 „  ƒ  YZ d e f d „  ƒ  YZ d S(   i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsNi   (   t   make_axes_locatablet   Sizet   locatable_axes_factory(   t   Axesg{®Gáz„?c         C` sC  t  |  ƒ } t j | t j |  ƒ ƒ } t j d d | d t j |  ƒ ƒ } t j d d | d t j |  ƒ ƒ } | j t j |  ƒ | | g ƒ | j | | | | | g ƒ |  j | j d d d d ƒƒ g  } | d k ry t
 |  j ƒ } Wqt k
 rt
 t |  ƒ ƒ } qXn  xì d d d g D]Û }	 | |  j ƒ  |  j d	 t ƒ d
 |  d |  ƒ}
 | j d d d |	 ƒ } |
 j | ƒ x1 |
 j j ƒ  |
 j j ƒ  D] } | j t ƒ q¢Wy. x' |
 j j ƒ  D] } | j j t ƒ qÌWWn t k
 rún X| j |
 ƒ q-W| r?|  j ƒ  } x | D] }
 | j |
 ƒ q%Wn  | S(   u,   
    pad : fraction of the axes height.
    g      ð?g       @g      @i    t   ny1iÿÿÿÿi   i   t   originalt   sharext   shareyt   nxt   nyN(   R   R   t   Fractiont   AxesYt   AxesXt   set_horizontalt   set_verticalt   set_axes_locatort   new_locatort   NoneR   t   _axes_classt   AttributeErrort   typet
   get_figuret   get_positiont   Truet   yaxist   get_ticklabelst   xaxist   set_visiblet   Falset   axist   valuest   major_ticklabelst   appendt   add_axes(   t   axt   padt
   axes_classt   add_allt   dividert   pad_sizet   xsizet   ysizet   ax_rgbR   t   ax1t   locatort   tR!   t   fig(    (    s?   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_rgb.pyt   make_rgb_axes   s@    ''#c         K` sÌ   | j  \ } } t j | | d g d d ƒ} | | d  d  … d  d  … d f <t j | ƒ } | | d  d  … d  d  … d f <t j | ƒ }	 | |	 d  d  … d  d  … d f <| | |	 }
 |  j |
 |  } | S(   Ni   t   dtypeu   di    i   i   (   t   shapet   npt   zerost
   zeros_liket   imshow(   R&   t   rt   gt   bt   kwargsR   R   t   Rt   Gt   Bt   RGBt   im_rgb(    (    s?   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_rgb.pyt
   imshow_rgb<   s    t   RGBAxesBasec           B` s8   e  Z d  Z d „  Z d d d „ Z d „  Z d „  Z RS(   uè  base class for a 4-panel imshow (RGB, R, G, B)

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

    Attributes
    ----------
    _defaultAxesClass : matplotlib.axes.Axes
        defaults to 'Axes' in RGBAxes child class.
        No default in abstract base class
    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
    c      	   O` sI  | j  d d ƒ } | j  d t ƒ } y | j  d |  j ƒ } Wn: t k
 ry d } t j t t | ƒ t j ƒ  d ƒ n X| | | Ž  } t | ƒ } t	 j
 | t	 j | ƒ ƒ }	 t	 j
 d d | d	 t	 j | ƒ ƒ }
 t	 j
 d d | d	 t	 j | ƒ ƒ } | j t	 j | ƒ |	 |
 g ƒ | j | |	 | |	 | g ƒ | j | j d
 d
 d d ƒƒ g  } x d d d
 g D]| } | | j ƒ  | j d t ƒ d | d | | } | j d d d | ƒ } | j | ƒ | j j d t ƒ | j | ƒ qnW| |  _ | \ |  _ |  _ |  _ | r;| j ƒ  } | j | ƒ |  j ƒ  n  |  j ƒ  d S(   uÊ  
        Parameters
        ----------
        pad : float
            fraction of the axes height to put as padding.
            defaults to 0.0
        add_all : bool
            True: Add the {rgb, r, g, b} axes to the figure
            defaults to True.
        axes_class : matplotlib.axes.Axes

        kl :
            Unpacked into axes_class() init for RGB
        kwargs :
            Unpacked into axes_class() init for RGB, R, G, B axes
        u   padg        u   add_allu
   axes_classu¥   A subclass of RGBAxesBase must have a _defaultAxesClass attribute. If you are not sure which axes class to use, consider using mpl_toolkits.axes_grid1.mpl_axes.Axes.i   g      ð?g       @g      @i    R   iÿÿÿÿi   R	   R
   R   R   R   t
   ticklabelsN(   t   popR   t   _defaultAxesClassR   t   sixt   reraiset   syst   exc_infoR   R   R   R   R   R   R   R   R   R   R   R!   t   toggleR    R$   RA   R>   R?   R@   R%   t   add_RGB_to_figuret   _config_axes(   t   selft   klR=   R'   R)   R(   t   new_msgR&   R*   R+   R,   R-   R.   R   R/   R0   R2   (    (    s?   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_rgb.pyt   __init__f   s@    ''	u   wc         C` sU   xN |  j  |  j |  j |  j g D]. } | j j j | ƒ | j j j | ƒ q Wd S(   u´   Set the line color and ticks for the axes

        Parameters
        ----------
        line_color : any matplotlib color
        marker_edge_color : any matplotlib color
        N(	   RA   R>   R?   R@   R!   t   linet	   set_colort   major_tickst   set_markeredgecolor(   RO   t
   line_colort   marker_edge_colorR/   (    (    s?   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_rgb.pyRN   ¥   s    %c         C` sO   |  j  j ƒ  j |  j ƒ |  j  j ƒ  j |  j ƒ |  j  j ƒ  j |  j ƒ d S(   uL   Add the red, green and blue axes to the RGB composite's axes figure
        N(   RA   R   R%   R>   R?   R@   (   RO   (    (    s?   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_rgb.pyRM   ±   s    c         K` sR  | j  | j  k o  | j  k n sL t d j | j  | j  | j  ƒ ƒ ‚ n  t j | | | g ƒ } t j | ƒ } | | d d … d d … d f <t j | ƒ } | | d d … d d … d f <t j | ƒ } | | d d … d d … d f <|  j j | |  }	 |  j j | |  }
 |  j	 j | |  } |  j
 j | |  } |	 |
 | | f S(   u  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
        uA   Input shapes do not match.
r.shape = {}
g.shape = {}
b.shape = {}Ni    i   i   (   R5   t
   ValueErrort   formatR6   t   dstackR8   RA   R9   R>   R?   R@   (   RO   R:   R;   R<   R=   RA   R>   R?   R@   RB   t   im_rt   im_gt   im_b(    (    s?   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_rgb.pyRC   ¸   s    %	(   t   __name__t
   __module__t   __doc__RR   RN   RM   RC   (    (    (    s?   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_rgb.pyRD   L   s
   	?	t   RGBAxesc           B` s   e  Z e Z RS(    (   R_   R`   R   RG   (    (    (    s?   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_rgb.pyRb   ã   s   (   t
   __future__R    R   R   R   RH   t   numpyR6   t   axes_dividerR   R   R   RJ   t   mpl_axesR   R   R   R3   RC   t   objectRD   Rb   (    (    (    s?   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_rgb.pyt   <module>   s   "0	—