
    G8cks                        d Z ddlmZ ddlmZ ddlZddlmZm	Z	 ddl
mZ ddlmZ ddlmZ d Z G d	 d
      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d d e      Z G d! d"e      Z G d# d$e      Z G d% d&e      Z  G d' d(e      Z!y))a  
Default legend handlers.

.. important::

    This is a low-level legend API, which most end users do not need.

    We recommend that you are familiar with the :doc:`legend guide
    </tutorials/intermediate/legend_guide>` before reading this documentation.

Legend handlers are expected to be a callable object with a following
signature. ::

    legend_handler(legend, orig_handle, fontsize, handlebox)

Where *legend* is the legend itself, *orig_handle* is the original
plot, *fontsize* is the fontsize in pixels, and *handlebox* is a
OffsetBox instance. Within the call, you should create relevant
artists (using relevant properties from the *legend* and/or
*orig_handle*) and add them into the handlebox. The artists needs to
be scaled according to the fontsize (note that the size is in pixel,
i.e., this is dpi-scaled value).

This module includes definition of several legend handler classes
derived from the base class (HandlerBase) with the following method::

    def legend_artist(self, legend, orig_handle, fontsize, handlebox)
    )Sequence)cycleN)_apicbook)Line2D)	Rectanglec                 r    t        t        |j                               d       }|| j                  |       y y N)nextiterget_childrenupdate_from)tgtsrcfirst_childs      ;/usr/lib/python3/dist-packages/matplotlib/legend_handler.pyupdate_from_first_childr   )   s3    tC,,./6K$     c                   <    e Zd ZdZd
dZd Zd Zd Zd Zd Z	d	 Z
y)HandlerBasea   
    A Base class for default legend handlers.

    The derived classes are meant to override *create_artists* method, which
    has a following signature.::

      def create_artists(self, legend, orig_handle,
                         xdescent, ydescent, width, height, fontsize,
                         trans):

    The overridden method needs to create artists of the given
    transform that fits in the given dimension (xdescent, ydescent,
    width, height) that are scaled by fontsize if necessary.

    Nc                 0    ||c| _         | _        || _        y r
   )_xpad_ypad_update_prop_func)selfxpadypadupdate_funcs       r   __init__zHandlerBase.__init__?   s    !%t
DJ!,r   c                 f    | j                   | j                  ||       y | j                  ||       y r
   )r   _default_update_propr   legend_handleorig_handles      r   _update_propzHandlerBase._update_propC   s.    !!)%%m[A""=+>r   c                 &    |j                  |       y r
   )r   r"   s      r   r!   z HandlerBase._default_update_propI   s    !!+.r   c                     | j                  ||       |j                  |       |j                  d        |j                  d        y r
   )r%   _set_artist_propsset_clip_boxset_clip_pathr   r#   r$   legends       r   update_propzHandlerBase.update_propL   s<    -5  /""4(##D)r   c                     || j                   |z  z
  }|| j                  |z  z
  }|| j                   |z  z
  }|| j                  |z  z
  }||||fS r
   )r   r   )r   r,   r$   xdescentydescentwidthheightfontsizes           r   adjust_drawing_areazHandlerBase.adjust_drawing_areaT   s_     djj833djj833

X--$**x//5&00r   c                 <   | j                  |||j                  |j                  |j                  |j                  |      \  }}}}| j                  ||||||||j                               }	t        |	t              r|	d   g}	|	D ]  }
|j                  |
        |	d   S )a-  
        Return the artist that this HandlerBase generates for the given
        original artist/handle.

        Parameters
        ----------
        legend : `~matplotlib.legend.Legend`
            The legend for which these legend artists are being created.
        orig_handle : :class:`matplotlib.artist.Artist` or similar
            The object for which these legend artists are being created.
        fontsize : int
            The fontsize in pixels. The artists being created should
            be scaled according to the given fontsize.
        handlebox : `matplotlib.offsetbox.OffsetBox`
            The box which has been created to hold this legend entry's
            artists. Artists created in the `legend_artist` method must
            be added to this handlebox inside this method.

        r   )
r4   r/   r0   r1   r2   create_artistsget_transform
isinstance_Line2DHandleList
add_artist)r   r,   r$   r3   	handleboxr/   r0   r1   r2   artistsas              r   legend_artistzHandlerBase.legend_artist]   s    * -1,D,D##Y%7%7)"2"2	-)(E6
 %%fk&.%&.	0G0G0IK g01qzlG  	$A  #	$ qzr   c	                     t        d      )NzDerived must override)NotImplementedError)	r   r,   r$   r/   r0   r1   r2   r3   transs	            r   r6   zHandlerBase.create_artists   s     ""9::r   )        rB   N)__name__
__module____qualname____doc__r   r%   r!   r-   r4   r>   r6    r   r   r   r   /   s+    -?/*1&P;r   r   c                   0     e Zd ZdZd fd	Zd Zd Z xZS )HandlerNpointszM
    A legend handler that shows *numpoints* points in the legend entry.
    c                 @    t        |   di | || _        || _        y)a  
        Parameters
        ----------
        marker_pad : float
            Padding between points in legend entry.
        numpoints : int
            Number of points to show in legend entry.
        **kwargs
            Keyword arguments forwarded to `.HandlerBase`.
        NrG   )superr   
_numpoints_marker_pad)r   
marker_pad	numpointskwargs	__class__s       r   r   zHandlerNpoints.__init__   s$     	"6"#%r   c                 J    | j                   |j                  S | j                   S r
   )rL   rO   r   r,   s     r   get_numpointszHandlerNpoints.get_numpoints   s"    ??"###??"r   c                     | j                  |      }|dkD  r7| j                  |z  }t        j                  | |z   | |z   |z
  |      }	|	}
|	|
fS | | |z   g}	| d|z  z   g}
|	|
fS )N         ?)rT   rM   nplinspace)r   r,   r/   r0   r1   r2   r3   rO   padxdataxdata_markers              r   	get_xdatazHandlerNpoints.get_xdata   s    &&v.	q=""X-CKK	C!)	E 1C 7 )+E !L l"" Y	E 12E%Ie34Ll""r   )333333?N)rC   rD   rE   rF   r   rT   r]   __classcell__rQ   s   @r   rI   rI      s    & ##r   rI   c                   *     e Zd ZdZd fd	Zd Z xZS )HandlerNpointsYoffsetsz
    A legend handler that shows *numpoints* in the legend, and allows them to
    be individually offset in the y-direction.
    c                 6    t        |   dd|i| || _        y)aL  
        Parameters
        ----------
        numpoints : int
            Number of points to show in legend entry.
        yoffsets : array of floats
            Length *numpoints* list of y offsets for each point in
            legend entry.
        **kwargs
            Keyword arguments forwarded to `.HandlerNpoints`.
        rO   NrG   )rK   r   	_yoffsets)r   rO   yoffsetsrP   rQ   s       r   r   zHandlerNpointsYoffsets.__init__   s!     	7977!r   c                     | j                   ||j                  z  }|S |t        j                  | j                         z  }|S r
   rd   _scatteryoffsetsrX   asarrayr   r,   r/   r0   r1   r2   r3   ydatas           r   	get_ydataz HandlerNpointsYoffsets.get_ydata   sA    >>!V444E  RZZ77Er   NN)rC   rD   rE   rF   r   rl   r_   r`   s   @r   rb   rb      s    
"r   rb   c                       e Zd ZdZd Zy)HandlerLine2DCompoundz
    Original handler for `.Line2D` instances, that relies on combining
    a line-only with a marker-only artist.  May be deprecated in the future.
    c	                 :   | j                  ||||||      \  }	}
t        j                  |	||z
  dz        }t        |	|      }| j	                  |||       |j                  d       |j                  d       t        |
|d t        |
             }| j	                  |||       |j                  d       |j                  dk7  r.|j                         |j                  z  }|j                  |       ||_        |j                  |       |j                  |       ||gS )N   default NonerV   )r]   rX   	full_liker   r-   set_drawstyle
set_markerlenset_linestylemarkerscaleget_markersizeset_markersize
_legmarkerset_transform)r   r,   r$   r/   r0   r1   r2   r3   rA   r[   r\   rk   leglinelegline_markernewszs                  r   r6   z$HandlerLine2DCompound.create_artists   s    #nnVXx-2FHF| Ufx&71%<>&+v6i(2e4FS5F.GHf=$$V,""113f6H6HHE))%0 ,e$$$U+((r   NrC   rD   rE   rF   r6   rG   r   r   ro   ro      s    
)r   ro   c                       e Zd Zd Zd Zd Zy)r9   c                     || _         y r
   )_legline)r   r   s     r   r   z_Line2DHandleList.__init__   s	    r   c                      yNrq   rG   )r   s    r   __len__z_Line2DHandleList.__len__   s    r   c                 p    |dk7  rt        j                  dd       | j                  | j                  g|   S )Nr   z3.5zuAccess to the second element returned by HandlerLine2D is deprecated since %(since)s; it will be removed %(removal)s.)message)r   warn_deprecatedr   )r   indexs     r   __getitem__z_Line2DHandleList.__getitem__   s;    A:     '( t}}-e44r   N)rC   rD   rE   r   r   r   rG   r   r   r9   r9      s     5r   r9   c                       e Zd ZdZd Zy)HandlerLine2Dz
    Handler for `.Line2D` instances.

    See Also
    --------
    HandlerLine2DCompound : An earlier handler implementation, which used one
                            artist for the line and another for the marker(s).
    c	                    | j                  ||||||      \  }	}
d }| j                  |      dk(  r t        j                  |	d   |	d   d      }	dg}t        j                  |	||z
  dz        }t        |	||      }| j                  |||       |j                  dk7  r.|j                         |j                  z  }|j                  |       |j                  |       t        |      S )NrV   r      rq   )	markevery)r]   rT   rX   rY   ru   r   r-   rz   r{   r|   r~   r9   )r   r,   r$   r/   r0   r1   r2   r3   rA   r[   r\   r   rk   r   r   s                  r   r6   zHandlerLine2D.create_artists  s     #nnVXx-2FHF| 	f%* KKa%)Q7EIUVh%6!$;<;+v6"**,v/A/AAE""5)e$ ))r   Nr   rG   r   r   r   r   
  s    *r   r   c                   0     e Zd ZdZd fd	Zd Zd Z xZS )HandlerPatchz)
    Handler for `.Patch` instances.
    c                 2    t        |   di | || _        y)a  
        Parameters
        ----------
        patch_func : callable, optional
            The function that creates the legend key artist.
            *patch_func* should have the signature::

                def patch_func(legend=legend, orig_handle=orig_handle,
                               xdescent=xdescent, ydescent=ydescent,
                               width=width, height=height, fontsize=fontsize)

            Subsequently the created artist will have its ``update_prop``
            method called and the appropriate transform will be applied.

        **kwargs
            Keyword arguments forwarded to `.HandlerBase`.
        NrG   )rK   r   _patch_func)r   
patch_funcrP   rQ   s      r   r   zHandlerPatch.__init__6  s    $ 	"6"%r   c           	      v    | j                   t        | | f||      }|S | j                  |||||||      }|S )Nxyr1   r2   )r,   r$   r/   r0   r1   r2   r3   )r   r   	r   r,   r$   r/   r0   r1   r2   r3   ps	            r   _create_patchzHandlerPatch._create_patchK  s^    #xi(3 %f6A    K*2X',Vh ! PA r   c	           	      ~    | j                  |||||||      }	| j                  |	||       |	j                  |       |	gS r
   )r   r-   r~   
r   r,   r$   r/   r0   r1   r2   r3   rA   r   s
             r   r6   zHandlerPatch.create_artistsV  sG    v{'5&(LK0	s
r   r
   )rC   rD   rE   rF   r   r   r6   r_   r`   s   @r   r   r   1  s    &*	r   r   c                   "    e Zd ZdZd Zd Zd Zy)HandlerStepPatchzA
    Handler for `~.matplotlib.patches.StepPatch` instances.
    c                 H    t        | | f|j                         ||      }|S )N)r   colorr1   r2   )r   get_facecolorr   s	            r   r   zHandlerStepPatch._create_patchd  s/    8)hY/'557!&2 r   c                     t        d|g|dz  |dz  g|j                         |j                         |j                               }|j	                  d       |j                  d       |S )Nr   rq   )r   	linestyle	linewidthrr   rs   )r   get_edgecolorget_linestyleget_linewidthrv   rw   )	r   r,   r$   r/   r0   r1   r2   r3   r   s	            r   _create_linezHandlerStepPatch._create_linel  sj     !UfQhq%9*88:#.#<#<#>#.#<#<#> 	i(2r   c	           	          |j                         s|j                         +| j                  |||||||      }	| j                  |	||       n| j	                  |||||||      }	|	j                  |       |	gS r
   )get_fill	get_hatchr   r-   r   r~   r   s
             r   r6   zHandlerStepPatch.create_artistsz  s    !k&;&;&=&I""6;#+XufhPAQV4!!&+"*HeVXOA	s
r   N)rC   rD   rE   rF   r   r   r6   rG   r   r   r   r   _  s    
r   r   c                   "    e Zd ZdZd Zd Zd Zy)HandlerLineCollectionz2
    Handler for `.LineCollection` instances.
    c                 J    | j                   |j                  S | j                   S r
   rL   scatterpointsrS   s     r   rT   z#HandlerLineCollection.get_numpoints  "    ??"'''??"r   c                     |j                         d   }|j                  d   }|j                         d   }|j                  |       |j	                  |       |j                  |       y Nr   )get_linewidths_us_linestyles
get_colors	set_colorry   set_linewidth)r   r#   r$   lwdashesr   s         r   r!   z*HandlerLineCollection._default_update_prop  sb    '')!,++A.&&(+&##F+##B'r   c	                     | j                  ||||||      \  }	}
t        j                  |	||z
  dz        }t        |	|      }| j	                  |||       |j                  |       |gS r   )r]   rX   ru   r   r-   r~   )r   r,   r$   r/   r0   r1   r2   r3   rA   r[   r\   rk   r   s                r   r6   z$HandlerLineCollection.create_artists  ss     #nnVXx-2FHF|UVh%6!$;<&+v6e$yr   N)rC   rD   rE   rF   rT   r!   r6   rG   r   r   r   r     s    #(r   r   c                   p     e Zd ZdZd fd	Zd Zd Zd Z ej                  ddd      d	        Z
d
 Z xZS )HandlerRegularPolyCollectionz'Handler for `.RegularPolyCollection`\s.c                 6    t        |   dd|i| || _        y )Nre   rG   )rK   r   _sizes)r   re   sizesrP   rQ   s       r   r   z%HandlerRegularPolyCollection.__init__  s    5(5f5r   c                 J    | j                   |j                  S | j                   S r
   r   rS   s     r   rT   z*HandlerRegularPolyCollection.get_numpoints  r   r   c                 r   | j                   |j                         }t        |      sdg}t        |      |j                  dz  z  }	t        |      |j                  dz  z  }
| j                  |      }|dk  rd|	|
z   z  |	|
gd | }|S |	|
z
  }|t        j                  dd|      z  |
z   }|S | j                   }|S )NrV   rq      rW   r   )	r   	get_sizesrx   maxrz   minrT   rX   rY   )r   r,   r$   r/   r0   r1   r2   r3   handle_sizessize_maxsize_minrO   r   rngs                 r   r   z&HandlerRegularPolyCollection.get_sizes  s    ;;&002L|$ !s<(6+=+=+BBH<(6+=+=+BBH**62I1}x(23X!##-I/   (*bkk!Q	::XE  KKEr   c                     | j                  ||       |j                  |j                         |j                  d        |j	                  d        y r
   )r%   
set_figurefigurer)   r*   r+   s       r   r-   z(HandlerRegularPolyCollection.update_prop  s@    -5  /""4(##D)r   3.6transOffsetoffset_transformc                 f     t        |      |j                         |j                         |||      S )N)rotationr   offsetsr   )typeget_numsidesget_rotationr   r$   r   r   r   s        r   create_collectionz.HandlerRegularPolyCollection.create_collection  s6     tK $$& --/u.>
 	
r   c	           
      ,   | j                  ||||||      \  }	}
| j                  ||||||      }| j                  |||||||      }| j                  ||t	        t        |
|            |      }| j                  |||       |j                  |       |gS N)r   r   )r]   rl   r   r   listzipr-   set_offset_transform)r   r,   r$   r/   r0   r1   r2   r3   rA   r[   r\   rk   r   r   s                 r   r6   z+HandlerRegularPolyCollection.create_artists  s     #nnVXx-2FHF| vx$fh8 v{Hh$fh8 ""\512U # L 	K0	u%s
r   rm   )rC   rD   rE   rF   r   rT   r   r-   r   rename_parameterr   r6   r_   r`   s   @r   r   r     sF    2
#** T5-1CD
 E
r   r   c                   D    e Zd ZdZ ej
                  ddd      d        Zy)HandlerPathCollectionzDHandler for `.PathCollection`\s, which are used by `~.Axes.scatter`.r   r   r   c                 P     t        |      |j                         d   g|||      S )Nr   )r   r   r   )r   	get_pathsr   s        r   r   z'HandlerPathCollection.create_collection  s2     tK ""$Q'(.>
 	
r   NrC   rD   rE   rF   r   r   r   rG   r   r   r   r     s*    OT5-1CD
 E
r   r   c                   D    e Zd ZdZ ej
                  ddd      d        Zy)HandlerCircleCollectionz"Handler for `.CircleCollection`\s.r   r   r   c                 *     t        |      |||      S r   )r   r   s        r   r   z)HandlerCircleCollection.create_collection  s      tK 75EG 	Gr   Nr   rG   r   r   r   r     s,    -T5-1CDG EGr   r   c                   4     e Zd ZdZ	 	 d fd	Zd Zd Z xZS )HandlerErrorbarzHandler for Errorbars.c                 F    || _         || _        t        |   d||d| y )N)rN   rO   rG   )
_xerr_size
_yerr_sizerK   r   )r   	xerr_size	yerr_sizerN   rO   rP   rQ   s         r   r   zHandlerErrorbar.__init__  s*     $#NJ)NvNr   c                 j    | j                   |z  }| j                  |}||fS | j                  |z  }||fS r
   )r   r   )	r   r,   r/   r0   r1   r2   r3   r   r   s	            r   get_err_sizezHandlerErrorbar.get_err_size  sG    OOh.	??"!I )## (2I)##r   c	                 ,   |\  }	}
}| j                  ||||||      \  }}t        j                  |||z
  dz        }t        ||      }t        j                  |      }t        j                  |d t        |             }| j                  ||||||      \  }}t        ||      }|	#|j                  d       |j                  d       n| j                  ||	|       |j                  d       |j                  d       | j                  ||	|       |j                  d       |j                  dk7  r.|j                         |j                  z  }|j                  |       g }g }|j                  rt!        ||      D cg c]  \  }}||z
  |f||z   |ff }}}t#        j$                  |      }| j                  ||d   |       |j'                  |       |
rt        ||z
  |      }t        ||z   |      }| j                  ||
d   |       | j                  ||
d   |       |j                  d       |j                  d       |j'                  |       |j'                  |       |j(                  rt!        ||      D cg c]  \  }}|||z
  f|||z   ff }}}t#        j$                  |      }| j                  ||d   |       |j'                  |       |
rt        |||z
        }t        |||z         }| j                  ||
d   |       | j                  ||
d   |       |j                  d	       |j                  d	       |j'                  |       |j'                  |       g ||||}|D ]  }|j+                  |        |S c c}}w c c}}w )
Nrq   Frr   nonert   rV   r   |_)r]   rX   ru   r   ri   rx   r   set_visibler-   rv   rw   ry   rz   r{   r|   has_xerrr   mcollLineCollectionappendhas_yerrr~   )r   r,   r$   r/   r0   r1   r2   r3   rA   	plotlinescaplinesbarlinecolsr[   r\   rk   r   ydata_markerr   r   r   r   handle_barlinecolshandle_caplinesxyvertscollcapline_leftcapline_rightr<   artists                                  r   r6   zHandlerErrorbar.create_artists  s    ,7(	8["nnVXx-2FHF| UVh%6!$;<&zz,/zz%(:\):";<#00816 J	9  l; &&&u-Wi8!!),v&^Y?((0!!Q&&557&:L:LL--e4!$\<!@BA 9}a(1y=!*<= BE B''.DT;q>6:%%d+%lY&>M &|i'? N  x{FC  VD'',((-&&|4&&}5!$\<!@BA !i-(1a)m*<= BE B''.DT;q>6:%%d+%lL94LM &|\I5M N  x{FC  VD'',((-&&|4&&}5

"1
3:
<J
  	(F  '	(QB$Bs   =N
?N)rW   Nr^   N)rC   rD   rE   rF   r   r   r6   r_   r`   s   @r   r   r     s     04+/O	$Rr   r   c                   :     e Zd ZdZ	 	 d fd	Zd Zd Zd Z xZS )HandlerStemz6
    Handler for plots produced by `~.Axes.stem`.
    c                 :    t        |   d|||d| || _        y)a  
        Parameters
        ----------
        marker_pad : float, default: 0.3
            Padding between points in legend entry.
        numpoints : int, optional
            Number of points to show in legend entry.
        bottom : float, optional

        yoffsets : array of floats, optional
            Length *numpoints* list of y offsets for each point in
            legend entry.
        **kwargs
            Keyword arguments forwarded to `.HandlerNpointsYoffsets`.
        )rN   rO   re   NrG   )rK   r   _bottom)r   rN   rO   bottomre   rP   rQ   s         r   r   zHandlerStem.__init__t  s-    " 	 	6J)"*	6.4	6r   c                     | j                   |d|j                  z  dz   z  }|S |t        j                  | j                         z  }|S )NrW   rg   rj   s           r   rl   zHandlerStem.get_ydata  sK    >>!cF$;$;;cABE  RZZ77Er   c	           	      \   |\  }	}
}t        |
t        j                        }| j                  ||||||      \  }}| j	                  ||||||      }| j
                  d}n| j
                  }t        ||d t        |             }| j                  ||	|       t        ||      D cg c]  \  }}t        ||g||g       }}}|rFt        j                  | | j                        5  |D ]  }| j                  ||
|        	 d d d        n't        ||
      D ]  \  }}| j                  |||        t        t        j                  |      t        j                  |      g||g      }| j                  |||       g |||}|D ]  }|j!                  |        |S c c}}w # 1 sw Y   zxY w)NrB   )r   )r8   r   r   r]   rl   r  r   rx   r-   r   r   _setattr_cm_copy_collection_propsrX   r   r   r~   )r   r,   r$   r/   r0   r1   r2   r3   rA   
markerline	stemlinesbaselineusing_linecollr[   r\   rk   r  leg_markerliner  r  leg_stemlineslinelmmleg_baseliner<   r
  s                              r   r6   zHandlerStem.create_artists  s    +6'
Ix $Iu/C/CD"nnVXx-2FHF| vx$fh8 <<F\\Fe4FS5F.GHV< &)u%=?!Q  A4 ? ?  ""D,G,GI >) >D$$T9f=>> > ]I6 0A  Q/0 rvve}bffUm<%v.0x8@M@<@@ 	(F  '	(-?> >s   %F%F""F+c                     |j                  |j                         d          |j                  |j                         d          y)zt
        Copy properties from the `.LineCollection` *orig_handle* to the
        `.Line2D` *legend_handle*.
        r   N)r   	get_colorry   r   r"   s      r   r  z"HandlerStem._copy_collection_props  s<    
 	 5 5 7 :;##K$=$=$?$BCr   )r^   NNN)	rC   rD   rE   rF   r   rl   r6   r  r_   r`   s   @r   r  r  o  s&     26'+*-^Dr   r  c                   *     e Zd ZdZd fd	Zd Z xZS )HandlerTuplez
    Handler for Tuple.
    c                 @    || _         || _        t        |   di | y)a  
        Parameters
        ----------
        ndivide : int, default: 1
            The number of sections to divide the legend area into.  If None,
            use the length of the input tuple.
        pad : float, default: :rc:`legend.borderpad`
            Padding in units of fraction of font size.
        **kwargs
            Keyword arguments forwarded to `.HandlerBase`.
        NrG   )_ndivide_padrK   r   )r   ndividerZ   rP   rQ   s       r   r   zHandlerTuple.__init__  s#      	"6"r   c	                    |j                         }	| j                  t        |      }
n| j                  }
| j                  |j                  |z  }n| j                  |z  }|
dkD  r|||
dz
  z  z
  |
z  }t        |||z   t        j                  |
      z  z
        }g }|D ]\  }|j                  |	|      }|j                  ||t        |      |||||      }t        |t              r|d   g}|j                  |       ^ |S )NrV   r   )get_legend_handler_mapr#  rx   r$  	borderpadr   rX   arangeget_legend_handlerr6   r   r8   r9   extend)r   r,   r$   r/   r0   r1   r2   r3   rA   handler_mapr%  rZ   	xds_cyclea_listhandle1handler_a_lists                    r   r6   zHandlerTuple.create_artists  s    335== +&GmmG99""X-C))h&CQ;SGaK00G;E(eckRYYw5G%GGH	" 	#G//WEG,,Y5&(EKG '#45"1:,MM'"	# r   )rV   N)rC   rD   rE   rF   r   r6   r_   r`   s   @r   r!  r!    s    # r   r!  c                       e Zd ZdZd Zd Zy)HandlerPolyCollectionza
    Handler for `.PolyCollection` used in `~.Axes.fill_between` and
    `~.Axes.stackplot`.
    c                 R   d }d } ||j                               |_         ||j                               |_        |j                  |_        |j
                  |_        |j                         |_        |j                         |_	        |j                  |_
        |j                   ||j                                      |j                   ||j                                      |j                   ||j!                                      |j#                  |j%                                y )Nc                 >    | j                   dk(  ryt        | d         S )Nr   )r   r   r   r   )sizetuple)colorss    r   first_colorz7HandlerPolyCollection._update_prop.<locals>.first_color  s     {{a###r   c                 $    t        |       r| d   S y r   )rx   )
prop_arrays    r   	get_firstz5HandlerPolyCollection._update_prop.<locals>.get_first  s    :!!}$r   )r   
_facecolorr   
_edgecolor_original_facecolor_original_edgecolorr   _fillr   _hatch_hatch_colorr   r   ry   get_linestylesr~   get_transformsr   
get_figure)r   r#   r$   r9  r<  s        r   r%   z"HandlerPolyCollection._update_prop  s    	$
	 $/{/H/H/J#K #.{/H/H/J#K ,7,K,K),7,K,K))224*446%0%=%="##Ik.H.H.J$KL##Ik.H.H.J$KL##Ik.H.H.J$KL  !7!7!9:r   c	                 t    t        | | f||      }	| j                  |	||       |	j                  |       |	gS )Nr   )r   r-   r~   r   s
             r   r6   z$HandlerPolyCollection.create_artists"  sA    8)hY/!&2K0	s
r   N)rC   rD   rE   rF   r%   r6   rG   r   r   r3  r3     s    ;:r   r3  )"rF   collections.abcr   	itertoolsr   numpyrX   
matplotlibr   r   matplotlib.linesr   matplotlib.patchesr   matplotlib.collectionscollectionsr   r   r   rI   rb   ro   r9   r   r   r   r   r   r   r   r   r  r!  r3  rG   r   r   <module>rP     s   : %   " # ( &%Y; Y;x'#[ '#T^ <")N ")J5 5$$*N $*N+; +\%{ %PM @F#9 FR
8 
G: Ghm hVWD( WDt4; 4n(K (r   