
    G8c              	          d dl Z d dlZd dlmZ d dlZd dl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Zd dlmZ d dlm Z d dlmZ d dlmZ d dlmZ d dlmZ d dl m!Z! d Z" e
d	gd
      d        Z# e
dgd
      d        Z$ e
dg      d        Z% e
dgd
      d        Z&d Z' e
dgd
      d        Z( e
dgd
      d        Z) e
dgd
 ejT                         dk(  rd nd      d        Z+ e
dgd
 ejT                         dk(  rd nd      d        Z, e
dgd
      d         Z- e
d!gd
 ejT                         dk(  rd nd"      d#        Z. e
d$d%gd
      d&        Z/ e
d'gd
      d(        Z0 e
d)gd
d*+      d,        Z1d- Z2 G d. d/      Z3 G d0 d1      Z4 e
d2g      d3        Z5d4 Z6d5 Z7d6 Z8 e
d7g      d8        Z9 e
d9g      d:        Z:d; Z;d< Z<d= Z=d> Z>d? Z?d@ Z@dA ZAdB ZBdC ZCej                  j                  dDdE      dF        ZFej                  j                  dDdE      dG        ZGej                  j                  dHdI      dJ        ZHdK ZIdL ZJdM ZKdN ZLej                  j                  dHdI      dO        ZMdP ZNdQ ZOdR ZPdS ZQdT ZRdU ZSdV ZTedW        ZUdX ZVdY ZWej                  j                  dZd[d\gd] ej                  d[d\g      g      d^        ZYej                  j                  d_d`daeZg      db        Z[ej                  j                  dZd[d\gd] ej                  d[d\g      g      dc        Z\dd Z]de Z^df Z_dg Z`dh Zadi Zbdj Zc e	       dk        Zdy)l    N)mock)check_figures_equalimage_comparison)needs_usetex)HandlerTuple)
rc_context)FontPropertiesc                     t         j                  j                  d      } t         j                  j                  d      }dgdz  dgdz  z   }dgdz  dgdz  z   }t        j                         \  }}t        | |||      D ]  \  }}}}	|j                  ||||	        |j                         \  }
}t        j                  t        ||
            }|j                  |j                         |j                         dd	
       y )N
   a   brg)labelccenter left)         ?)locbbox_to_anchor)nprandomrandnpltsubplotszipscatterget_legend_handles_labelscollectionsOrderedDictlegendvalueskeys)XYlabelscolorsfigaxxyr   colorhandlesr"   s               >/usr/lib/python3/dist-packages/matplotlib/tests/test_legend.pytest_legend_ordereddictr0      s     			A
		AUQY#"FUQY#"FllnGC!!Q7 /1eU


1au
./ 224OGV$$S%9:FIIfmmov{{}  9    legend_auto1T)remove_textc                      t        j                         \  } }t        j                  d      }|j	                  |d|z
  dd       |j	                  ||dz
  dd       |j                  d       y	)
Test automatic legend placementd   2   oy=1r   y=-1bestr   N)r   r   r   arangeplotr"   )r)   r*   r+   s      r/   test_legend_auto1r@   (   s^     llnGC
		#AGGArAvs%G(GGAq2vs&G)II&Ir1   legend_auto2c                      t        j                         \  } }t        j                  d      }|j	                  ||dd      }|j	                  ||ddd   dd      }|j                  |d   |d   gd	d
gd       y)r5   r6   edgem)alignr-   Nr   r   updownr<   r=   )r   r   r   r>   barr"   )r)   r*   r+   b1b2s        r/   test_legend_auto2rL   2   sv     llnGC
		#A	1F#	.B	1TrT7&	4BIIr!ubentVn&I9r1   legend_auto3c                      t        j                         \  } }g d}g d}|j                  ||dd       |j                  dd       |j	                  dd       |j                  d	       y
)r5   )?皙?rP   rO   rO   r   )ffffff?rQ   皙?rR   r   r   zo-liner:                 ?r<   r=   N)r   r   r?   set_xlimset_ylimr"   )r)   r*   r+   r,   s       r/   test_legend_auto3rX   <   s[     llnGC&A*AGGAq$fG%KKSKKSII&Ir1   legend_various_labelsc                  d   t        j                         } | j                  d      }|j                  t	        j
                  d      dd       |j                  t	        j                  dd      dd       |j                  t	        j
                  ddd      dd	       |j                  dd
       y )Ny      r8   r   r:   gffffff@u   DéveloppésrF   __nolegend__r<   )	numpointsr   )r   figureadd_subplotr?   r   r>   linspacer"   r)   r*   s     r/   test_various_labelsrc   H   s     **,C		BGGBIIaL#QG'GGBKK3NG;GGBIIaBNG;IIvI&r1   c                     t        j                         \  } }|j                  ddgd      \  }t        j                  t
        d      5  |j                  |g      }ddd       t        j                        dk(  sJ y# 1 sw Y   $xY w)	z
    Test that artists with labels starting with an underscore are not added to
    the legend, and that a warning is issued if one tries to add them
    explicitly.
    r   r   _foor:   z*starts with '_'.*excluded from the legend.matchr.   N)	r   r   r?   pytestwarnsUserWarningr"   lenlegendHandles)r)   r*   rS   r"   s       r/   )test_legend_label_with_leading_underscorern   S   s     llnGCGGQF&G)ED	kI
K +D6*+ v##$)))+ +s   
BB
zlegend_labels_first.pngc                  L   t        j                         \  } }|j                  t        j                  d      dd       |j                  t        j
                  d      dz  dd       |j                  t        j                  ddd	      d
d       |j                  dd       y )Nr   -or   r:   r   z:xr+      rF   ddiamondr<   F)r   markerfirst)r   r   r?   r   r>   onesr"   rb   s     r/   test_labels_firstrv   a   sz     llnGCGGBIIbM4qG)GGBGGBKM4sG+GGBIIb"b!3iG8II&eI,r1   zlegend_multiple_keys.pngc                  ,   t        j                         \  } }|j                  g dd      \  }|j                  g dd      \  }|j                  g dd      \  }|j                  ||f||f|gg dd||ft	        d 	      ||ft	        d d
      i       y )Nr         rp   ry   rz   r\   z-x)rz   r\   r   z-d)ztwo keyszpad=0zone keyr   )ndivider   )r|   pad)r^   handler_map)r   r   r?   r"   r   )r)   r*   p1p2p3s        r/   test_multiple_keysr   k   s     llnGC
'')T
"CB
'')T
"CB
'')T
"CBIIBx"b2&(H8\$%?8\$A%FH  Ir1   zrgba_alpha.pngx86_64g{Gz?)r3   tolc                      t        j                         \  } }|j                  t        d      d       t        j                  dgd      }|j
                  j                  g d       y )Nr   r   lwLonglabel that will go awaycenterr=   r   r   r   r   )r   r   r?   ranger"   legendPatchset_facecolorr)   r*   legs      r/   test_alpha_rgbar   x   sM     llnGCGGE"I!G
**34(
CCOO!!.1r1   zrcparam_alpha.pngc                  .   t        j                         \  } }|j                  t        d      d       t	        j
                  ddi      5  t        j                  dgd	      }|j                  j                  g d
       d d d        y # 1 sw Y   y xY w)Nr   r   r   zlegend.framealphag      ?)rcr   r   r=   r   )	r   r   r?   r   mplr   r"   r   r   r   s      r/   test_alpha_rcparamr      sv     llnGCGGE"I!G	/5	6 6jj78hG
 	%%n56 6 6s   6BBfancyc                     t        j                  d       t        j                  dgdz  dd       t        j                  t	        j
                  d      t	        j
                  ddd      d	       t        j                  t	        j
                  d      t	        j
                  d      d
d
d       t        j                  ddd
gdddd       y )Nr[   r   r   zo--XXr:   r   rF   zXX
XXr   )xerryerrr   r   rU   ry   T	My legendr   )r   r   ncolsshadowtitler^   )r   subplotr?   r   r   r>   errorbarr"    r1   r/   
test_fancyr      s     KKHHaS2XuD)KK		"ryyQ38DLL2		"C'JJ=#st;!Er1   
framealphag{Gz?c                      t        j                  ddd      } | }t        j                  | |dd       t        j                  d       y )Nr   r6   mylabelr   )r   r   r   )r   )r   ra   r   r?   r"   )r+   r,   s     r/   test_framealphar      s9     	AsC A	AHHQr*JJ#r1   scatter_rc3scatter_rc1c                     t        j                          t        j                  d      } | j                  t	        j
                  d      t	        j
                  ddd      d       | j                  ddd	gd
       dt        j                  d<   t        j                          t        j                  d      } | j                  t	        j
                  d      t	        j
                  ddd      d       | j                  ddd	gd
       y )Nr[   r   r   rF   threer:   r   rU   r   r   )r   r   r   r   zlegend.scatterpointsone)	r   r_   r   r   r   r>   r"   r   rcParams)r*   s    r/   test_rcr      s     JJL	S	BJJryy}biiAr2'JBII-c
  ! ,-CLL'(JJL	S	BJJryy}biiAr2%J@II-c
  !r1   legend_expandc                     ddg} t        j                  t        |       d      \  }}t        j                  d      }t        ||       D ]  \  }}|j                  |d|z
  dd       |j                  d	|
      }|j                  |       |j                  ||dz
  dd       |j                  d|
      }|j                  |       |j                  d|d        y)zTest expand modeNexpandr   r6   r7   r8   r9   r:   z
upper left)r   moder;   rightz
lower leftry   )r   r   r   )	r   r   rl   r   r>   r   r?   r"   
add_artist)legend_modesr)   axsr+   r*   r   l1l2s           r/   test_legend_expandr      s     (#L||C-q1HC
		#A\* 8D
263e,YY<dY3
b
1r63f-YY7Y.
b
		lQ	78r1   hatchingdefault)r3   stylec            	         dt         j                  d<   t        j                         \  } }t        j                  ddddd      }|j	                  |       t        j                  dddd	d
d      }|j	                  |       t        j                  dddddd      }|j	                  |       t        j                  dddd	dd
d      }|j	                  |       |j                  g dg dg ddd       |j                  g dg dg dddd       |j                  dd       |j                  dd       |j                  dd       y ) N   ztext.kerning_factor)r   r   333333?xxzPatch
default color
filled)hatchr   )Q?r   z||C1zPatch
explicit color
filled)r   	edgecolorr   )r   皙?FzPatch
default color
unfilled)r   fillr   )r   r   zPatch
explicit color
unfilled)r   r   r   r   )r   g333333?r   )皙?r   r   )rO   rU   rO   +zPath
default color)r   gQ?g)\(?C2zPath
explicit colorg{Gzg?r\   )handlelengthhandleheight)	r   r   r   	Rectangle	add_patchfill_betweenrV   rW   r"   )r)   r*   patchs      r/   test_hatchingr      s4    +,CLL&'llnGC MM&#s$ >@ELLMM)S#TT ?AELLMM(CDu @BELLMM+sCt%$( ACE LL OOL,%:  <OOO\=5K  M KKsKKsII11I-r1   c                  2   t        j                         \  } }|j                  t        d            }| j	                  |d      }|j                          | j                  g k(  sJ |j	                  d      }|j                          |j                         J y )Nr   test)r   r   r?   r   r"   removelegends
get_legend)r)   r*   linesr   s       r/   test_legend_remover      sw    llnGCGGE"IE
**UF
#CJJL;;"
))F
CJJL==?"""r1   c                   N    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zy)TestLegendFunctionc                    t        j                  t        d      d      }t        j                  d      5 }t        j
                          d d d        j                  t        j                         |dg       y # 1 sw Y   0xY w)Nr   hello worldr:   matplotlib.legend.Legendr   r?   r   r   r   r"   assert_called_withgcaselfr   Legends      r/   test_legend_no_argsz&TestLegendFunction.test_legend_no_args   s]    r-8ZZ23 	vJJL	!!#'')U]OD	 	s   A::Bc                    t        j                  t        d            }t        j                  d      5 }t        j
                  |dg       d d d        j                  t        j                         |dg       y # 1 sw Y   0xY w)Nr   r   r   r   r   s      r/   %test_legend_positional_handles_labelsz8TestLegendFunction.test_legend_positional_handles_labels   sb    r#ZZ23 	/vJJu}o.	/!!#'')U]OD	/ 	/s   A;;Bc                     t        j                  t        d            }t        j                  t
        d      5  t        j                  |       d d d        y # 1 sw Y   y xY w)Nr   zbut found an Artistrf   )r   r?   r   ri   raises	TypeErrorr"   )r   r   s     r/   #test_legend_positional_handles_onlyz6TestLegendFunction.test_legend_positional_handles_only   sF    r#]]9,AB 	 JJu	 	 	s   AA"c                    t        j                  t        d      d      }t        j                  d      5 }t        j
                  dg       d d d        j                  t        j                         |dg       y # 1 sw Y   0xY w)Nr   r   r:   r   foobarr   r   s      r/   "test_legend_positional_labels_onlyz5TestLegendFunction.test_legend_positional_labels_only  sb    r-8ZZ23 	#vJJz"	#!!#'')UXJ?	# 	#s   A<<Bc                    t        j                  t        d      d      }t        j                  d      5 }t        j
                  |dgd       d d d        j                  t        j                         |dgd       y # 1 sw Y   2xY w)Nr   r   r:   r   r   r   r=   r   r   s      r/   test_legend_three_argsz)TestLegendFunction.test_legend_three_args  sk    r-8ZZ23 	7vJJuxjg6	7!!#'')UXJG!L	7 	7s   BB
c                 *   t        j                  t        d      d      }t        j                  d      5 }|dgf|_        t        j                  ddi       d d d        j                  t        j                         gddi       y # 1 sw Y   1xY w)Nr   r   r:   z,matplotlib.legend._get_legend_handles_labels1ry   )r~   )	r   r?   r   r   r   return_valuer"   r   r   )r   r   handles_labelss      r/   test_legend_handler_mapz*TestLegendFunction.test_legend_handler_map  s|    r-8ZZ 5 6 	-9G*/-*@N'JJC8,	- 	))3779+Qx@		- 	-s   #B		Bc                    t        j                         \  }}t        j                  ddd      }|j	                  ||d      \  }|j	                  |d|z  d      \  }|j	                  |d|z  d	      \  }t        j                  d
      5 }|j                  ||g       d d d        j                  |||gd	dg       y # 1 sw Y   !xY w)Nr   r      r+   r:   ry   2xrz   3xr   rh   	r   r   r   ra   r?   r   r   r"   r   )r   r)   r*   r+   ln1ln2ln3r   s           r/   test_legend_kwargs_handles_onlyz2TestLegendFunction.test_legend_kwargs_handles_only  s    ,,.RKK1b!wwq!3w'wwq!A#Tw*wwq!A#Tw*ZZ23 	*vIIsCjI)	*!!"sCj4,?	* 	*s   CC
c                 `   t        j                         \  }}t        j                  ddd      }|j	                  ||      \  }|j	                  |d|z        \  }t        j                  d      5 }|j                  ddg       d d d        j                  |||gddg       y # 1 sw Y   !xY w)	Nr   r   r   ry   r   r+   r   r'   r   )r   r)   r*   r+   r   r   r   s          r/   test_legend_kwargs_labels_onlyz1TestLegendFunction.test_legend_kwargs_labels_only$  s    ,,.RKK1b!wwq!}wwq!A#ZZ23 	*vIIc4[I)	*!!"sCj3+>	* 	*s   /B$$B-c                    t        j                         \  }}t        j                  ddt        j                  z  d      }|j                  |t        j                  |      d      \  }|j                  |t        j                  |      d      \  }t        j                  d      5 }|j                  d||f	       d d d        j                  |||fd       y # 1 sw Y   xY w)
Nr   ry      sinr:   cosr   r   r   )r'   r.   )r   r   r   ra   pir?   r   r  r   r   r"   r   )r   r)   r*   thlnslncr   s          r/   !test_legend_kwargs_handles_labelsz4TestLegendFunction.test_legend_kwargs_handles_labels-  s    ,,.R[[AbeeGT*wwr266":Uw3wwr266":Uw3ZZ23 	=vIIZ#sI<	= 	!!"sCj*=	= 	=s   'CC$c                    t        j                         \  }}t        j                  ddt        j                  z  d      }|j                  |t        j                  |      d      \  }|j                  |t        j                  |      d      \  }t        j                  t              5 }|j                  ||fd       d d d        t              d	k(  sJ t        |d   j                        d
k(  sJ y # 1 sw Y   7xY w)Nr   ry   r   r   r:   r  r  r   r   MYou have mixed positional and keyword arguments, some input may be discarded.)r   r   r   ra   r  r?   r   r  ri   rj   rk   r"   rl   strmessage)r   r)   r*   r  r  r  records          r/   test_warn_mixed_args_and_kwargsz2TestLegendFunction.test_warn_mixed_args_and_kwargs7  s    ,,.R[[AbeeGT*wwr266":Uw3wwr266":Uw3\\+& 	5&IIsCjI4	56{a6!9$$% 	 	5 	5s   +C77D c                 R   ddl m}  |d      }|j                         }|j                  g dg dd      \  }|j                  g dg dd      \  }t	        j
                  d	      5 }t        j                          d d d        j                  |||gddg       y # 1 sw Y   !xY w)
Nr   )host_subploto   r   r   ry   Densityr:   )r   rz   ry   Temperaturer   )	mpl_toolkits.axes_grid1r  twinxr?   r   r   r   r"   r   )r   r  hostparr   r   r   s          r/   test_parasitez TestLegendFunction.test_parasiteC  s    8C jjlii	9Ii>hhy)=hAZZ23 	vJJL	!!$R9m2LM	 	s   (BB&N)__name__
__module____qualname__r   r   r   r   r   r   r   r   r  r  r  r   r1   r/   r   r      s@    EE@MA@?>
Nr1   r   c                   6    e Zd Zd Zd Zd Zd Zd Zd Zd Z	y)	TestLegendFigureFunctionc                     t        j                         \  }}|j                  t        d            }t	        j
                  d      5 }|j                  |dg       d d d        j                  ||dg|j                         y # 1 sw Y   *xY w)Nr   r   r   bbox_transform	r   r   r?   r   r   r   r"   r   transFigurer   r)   r*   r   r   s        r/   test_legend_handle_labelz1TestLegendFigureFunction.test_legend_handle_labelS  sz    ,,.Rb	"ZZ23 	/vJJu}o.	/!!#u}o14 	" 	B	/ 	/s   BBc                    t        j                         \  }}|j                  t        d      d      }t	        j
                  d      5 }|j                          d d d        j                  ||dg|j                         y # 1 sw Y   *xY w)Nr   r   r:   r   r  r!  r#  s        r/   r   z,TestLegendFigureFunction.test_legend_no_args[  sw    ,,.Rb	7ZZ23 	vJJL	!!#u}o14 	" 	B	 	s   	BBc                    t        j                         \  }}|j                  t        d            }t	        j
                  d      5 }|j                  dg       d d d        j                  ||dg|j                         y # 1 sw Y   *xY w)Nr   r   r   r  r!  r#  s        r/   test_legend_label_argz.TestLegendFigureFunction.test_legend_label_argc  sx    ,,.Rb	"ZZ23 	#vJJz"	#!!#uxj14 	" 	B	# 	#s   BBc                 $   t        j                         \  }}|j                  t        d            }t	        j
                  d      5 }|j                  |dgd       d d d        j                  ||dgd|j                         y # 1 sw Y   +xY w)Nr   r   r   r   r  r!  r#  s        r/   test_legend_label_three_argsz5TestLegendFigureFunction.test_legend_label_three_argsk  s~    ,,.Rb	"ZZ23 	3vJJuxj'2	3!!#uxj'14 	" 	B	3 	3s   BBc                     t        j                         \  }}|j                  t        d            }t	        j
                  t              5  |j                  |dgdd       d d d        y # 1 sw Y   y xY w)Nr   r   r   leftr=   )r   r   r?   r   ri   r   	Exceptionr"   )r   r)   r*   r   s       r/   #test_legend_label_three_args_pluskwz<TestLegendFigureFunction.test_legend_label_three_args_pluskws  s\     ,,.Rb	"]]9% 	?JJuxj'vJ>	? 	? 	?s   A++A4c                    t        j                  dd      \  }}|d   j                  t        d            }|d   j                  t	        j
                  d      dz        }t        j                  d      5 }|j                  dd||f	       d d d        j                  |||fdd|j                  
       y # 1 sw Y   ,xY w)Nr   ry   r   r          @r   r   r  )r   r'   r.   )r   r   )r   r   r?   r   r   r>   r   r   r"   r   r"  )r   r)   r   r   lines2r   s         r/   test_legend_kw_argsz,TestLegendFigureFunction.test_legend_kw_args{  s    <<1%SAE"I&QRYYr]R/0ZZ23 	PvJJ7:vJO	P!!%*'?? 	" 	,	P 	Ps   6B88Cc                    t        j                  dd      \  }}|d   j                  t        d            }|d   j                  t	        j
                  d      dz        }t        j                  t              5 }|j                  ||fd       d d d        t              dk(  sJ t        |d   j                        dk(  sJ y # 1 sw Y   7xY w)	Nr   ry   r   r   r/  r  r   r	  )r   r   r?   r   r   r>   ri   rj   rk   r"   rl   r
  r  )r   r)   r   r   r0  r  s         r/   test_warn_args_kwargsz.TestLegendFigureFunction.test_warn_args_kwargs  s    <<1%SAE"I&QRYYr]R/0\\+& 	;&JJvzJ:	;6{a6!9$$% 	 	; 	;s   :CCN)
r  r  r  r$  r   r'  r)  r-  r1  r3  r   r1   r/   r  r  Q  s)    BBBB?,	r1   r  zlegend_stackplot.pngc                  "   t        j                         \  } }t        j                  ddd      }d|z  }d|z  dz   }d|z  dz   }|j	                  ||||g d	       |j                  d
       |j                  d       |j                  d       y)z/Test legend for PolyCollection using stackplot.r   r   rU   r/  r   g      @ry   )y1y2y3r   )r   r   )r   F   r<   r=   N)r   r   r   ra   	stackplotrV   rW   r"   )r)   r*   r+   r5  r6  r7  s         r/   test_legend_stackplotr:    s     llnGC
Ar2A	qB	q1B	q1BLLBB'9L:KKKKII&Ir1   c                      t        j                         \  } }t        j                         \  }}|j                  t        d      t        d            }|j	                  |d       y )Nrz   foo)r   r   rI   r   r"   )r)   r*   fig2ax2brss        r/   test_cross_figure_patch_legendr@    sF    llnGCID#
&&q58
$CKKUr1   c            
          t        j                         \  } }|j                  t        j                  gt        j                  gdddd      }|j                  |gdg       t        j                         \  } }dD ]a  }d}t        j                  j                  d|      \  }}d	t        j                  j                  |      z  }|j                  |||||d
d       c |j                          |j                  d       y )Nr8   r   rz   )marker	facecolorr   sr   )redgreenbluei  ry   g      i@r   none)r   rD  r   alpha
edgecolorsT)	r   r   r   r   nanr"   r   randgrid)r)   r*   hr-   nr+   r,   scales           r/   test_nanscatterrQ    s    llnGC


BFF8bffXc C1 	 	6A IIqcI;llnGC) 1yy~~a#1		q))


1a5E 	 	1	1 IIKGGDMr1   c                     t        j                         \  } }|j                  ddddd       |j                  dddd	d       |j                          t	        j
                  |g      \  }}t        |      d
k(  sJ t        j                         \  } }|j                  ddddd       |j                  dddd	d       |j                          t	        j
                  |g      \  }}t        |      d
k(  sJ y )NrT   rU   kr8   r   )r-   rB  r   r   r   vry   )r   r   r   r"   mlegend_get_legend_handles_labelsrl   )r)   r*   handlabs       r/   test_legend_repeatcheckokrY    s    llnGCJJsCs3fJ=JJsCs3fJ=IIK22B48ID#s8q==llnGCJJsCs3fJ=JJsCs3fJ=IIK22B48ID#s8q==r1   znot_covering_scatter.pngc                  (   g d} t        d      D ]  }t        j                  |g|g| |          ! t        j                  g dd       t        j                         j                  dd       t        j                         j                  dd       y )	N)r   r   r   rz   )r-   )r<  r<  r<  r<   r=   g      g@)r   r   r   r"   r   rV   rW   )r(   rO  s     r/   test_not_covering_scatterr[    so    F1X /QC!F1I./ JJ$&1GGItS!GGItS!r1   z"not_covering_scatter_transform.pngc                  J   t        j                         j                  dd      } t        j                  ddd      }t        j                  ||       t        j                  dgdg| t        j                         j                  z          t        j                  dd	gd
       y )Nirq   r        r   )	transformr<  rI   r<   r=   )mtransformsAffine2D	translater   ra   r   r?   r   r   	transDatar"   )offsetr+   s     r/   #test_not_covering_scatter_transformre    su     !!#--c26F
Ar4 AHHQNKKrdfswwy/B/B&BCJJu~6*r1   c                  <   ddgddgg} ddgddggd	dgd
dggg}d
dgddggd	dgddggg}t        j                  | dd      }t        j                  |d      }t        j                  |dd	      }t        j                         \  }}|j	                  |       |j	                  |       |j	                  |       |j                  |||gg d      }|j                  \  }	}
}t        |||f|	|
|f      D ]'  \  }}|j                         d   |j                  k(  r'J  y )N)r   r   )r   r   )r   333333?)皙?rh  gffffff?rh  r   r   r   rg  rP   z--rz   )
linestylesr   z-.)ri  :)line1line2zline 3r   )
mcollectionsLineCollectionr   r   add_collectionr"   rm   r   get_linestyles_dash_pattern)lines1r0  lines3lc1lc2lc3r)   r*   r   h1h2h3ohlhs                 r/   !test_linecollection_scaled_dashesr|    sA    8X"67FRy2r(#r2hR%9:FRy2r(#r2hR%9:F

%
%f!
DC

%
%f
>C

%
%f
DCllnGCccc
))S#sO%A
BC""JBBsCoB|4 :B  "1%)9)9999:r1   c                      t        j                         \  } }|j                  t        d      d       |j	                  d       y)z(Test legend handler with numpoints <= 1.r   r   r:   r   r^   N)r   r   r?   r   r"   rb   s     r/   test_handler_numpointsr    s5     llnGCGGE!HFG#IIIr1   c                  "   t        j                         \  } }|j                  dddd       t        j                  t
              5 }|j                          ddd       t              dk(  sJ t        j                         \  }}|j                  t        j                  j                  ddd             t        j                         5  t        j                  d       |j                          ddd       y# 1 sw Y   xY w# 1 sw Y   yxY w)	z2Test that Text artists with labels raise a warningr   textr   )r+   r,   rD  r   Nr   )r   r   error)r   r   r  ri   rj   rk   r"   rl   
pcolormeshr   r   uniformwarningscatch_warningssimplefilterr   )r)   r*   r  fs       r/   test_text_nohandler_warningr    s    llnGCGGa1gG.	k	" f
		v;! LLNEArMM"))##Aq(34		 	 	" 'g&
$$&' ' ' 's   C9
&D9DDc                  \    t        j                  g g d       t        j                          y)z1Test legend when bar chart is empty with a label.r   r:   N)r   rI   r"   r   r1   r/    test_empty_bar_chart_with_legendr    s     GGB&!JJLr1   c                      t        j                         \  } }|j                  t        d      d       |j	                  dd      }|j                         j                         dk(  sJ y )Nr6   r   r:   Tw)r   rC  r   )r   r   r?   r   r"   	get_frame	get_alphar   s      r/   test_shadow_framealphar    sV     llnGCGGE#JfG%
))43)
/C==?$$&!+++r1   c                     t        j                         \  } }|j                  t        d             |j	                         }|j                         j                         dk(  sJ |j                         j                         rJ y )Nr    )r   r   r?   r   r"   	get_titleget_textget_visibler   s      r/   test_legend_title_emptyr     sf     llnGCGGE"I
))+C==?##%+++}}**,,,,r1   c                      t        j                  d      \  } }|j                  t        d      d       |j	                         }|j                  | j                  j                               j                  }t        j                  d      \  } }|j                  t        d      d       |j	                         }|j                  | j                  j                               j                  }t        j                  |dz  d      |k(  sJ y )	Nr6   dpir   Aardvarkr:      ry   rP   )r   r   r?   r   r"   get_window_extentcanvasget_rendererx0ri   approx)r)   r*   r   x01x02s        r/    test_legend_proper_window_extentr  +  s    lls#GCGGE"IZG(
))+C




 7 7 9
:
=
=Clls#GCGGE"IZG(
))+C




 7 7 9
:
=
=C==Q$+++r1   c                  "   t        j                  d      \  } }|j                  t        d      d       |j	                         }| j	                         }| j
                  j                          |j                          |j                          y )Nr6   r  r   r  r:   )r   r   r?   r   r"   r  drawr  )r)   r*   r   leg2s       r/   "test_window_extent_cached_rendererr  9  sd    lls#GCGGE"IZG(
))+C::<DJJOOr1   c                  N   t        j                  t        d             t        j                  t
              5  t        j                  ddddd       d d d        t        j                  dt        dd            } | j                         j                         dk(  sJ t        j                  dd	d
      \  }}|j                  }|d   j                  t        d             |d   j                  dd      }|j                         j                         dk(  sJ |d   j                  t        d             |d   j                  dddd      }|j                         j                         dk(  sJ |d   j                  t        d             d t        j                  d<   |d   j                  dddi      }|j                         j                         t        j                  d   k(  sJ |d	   j                  t        d             |d	   j                  d      }|j                         j                         t        j                  d   k(  sJ |d   j                  t        d             dt        j                  d<   |d   j                  dddi      }|j                         j                         dk(  sJ |d   j                  t        d             |d   j                  d      }|j                         j                         dk(  sJ y # 1 sw Y   xY w)Nr   r     serif)familysize)r   title_fontsizetitle_fontproperties)r   r  ry   rz   )r   r   )figsizer   )r   r  r   zlegend.title_fontsizer  z	font.sizer   r\   rq   r   )r   r?   r   ri   r   
ValueErrorr"   r	   r  get_sizer   flatget_fontsizer   r   )	r   r)   axesleg0leg1r  leg3leg4leg5s	            r/   #test_legend_title_fontprop_fontsizer  D  s   HHU2Y	z	" I

B3:B(G	II **:N.5B=@ AC==?##%+++Q73IC99DGLLr7>>
2>>D>>((*b000GLLr7>>
:A2/N  PD>>((*b000GLLr,0CLL()7>>
08'/B  DD>>((*cll;.GGGGGLLr7>>
>+D>>((*cll;.GGGGGLLr,.CLL()7>>
08'/B  DD>>((*b000GLLr7>>
>+D>>((*b000AI Is   LL$	alignment)r   r+  r   c                     t        j                         \  }}|j                  t        d      d       |j	                  d|       }|j                         d   j                  | k(  sJ |j                         | k(  sJ y )Nr   r   r:   r  )r   r  r   )r   r   r?   r   r"   get_childrenrE   get_alignmentr  r)   r*   r   s       r/   test_legend_alignmentr  j  sp    llnGCGGE"IVG$
))*	)
:Ca &&)333)+++r1   c                    t        j                         \  }}|j                  t        d      d       |j	                         }|j                  |        |j                         d   j                  | k(  sJ |j                         | k(  sJ y )Nr   r   r:   r   )	r   r   r?   r   r"   set_alignmentr  rE   r  r  s       r/   test_legend_set_alignmentr  s  sw    llnGCGGE"IVG$
))+Ci a &&)333)+++r1   r-   )rE  rH  )r   r   r   c                 N   t        j                         \  }}|j                  t        j                  d      t        j                  d      dz  d       |j                  t        j                  d      t        j                  d      dz  d       |j                  t        j                  d      t        j                  d      dz  d       |j                  | 	      }|j                         D ]2  }t        j                  j                  |j                         |       r2J  y )
Nr   r   #1r:   ry   #2rz   #3
labelcolor)r   r   r?   r   r>   r"   	get_textsr   r(   
same_color	get_colorr-   r)   r*   r   r  s        r/   test_legend_labelcolor_singler  }  s     llnGCGGBIIbM299R=?$G7GGBIIbM299R=?$G7GGBIIbM299R=?$G7
))u)
%C >zz$$T^^%5u===>r1   c                  p   t        j                         \  } }|j                  t        j                  d      t        j                  d      dz  d       |j                  t        j                  d      t        j                  d      dz  d       |j                  t        j                  d      t        j                  d      dz  d       |j                  g d	
      }t        |j                         g d	      D ]5  \  }}t        j                  j                  |j                         |      r5J  y )Nr   r   r  r:   ry   r  rz   r  r   r   r   r  r   r   r?   r   r>   r"   r   r  r   r(   r  r  r)   r*   r   r  r-   s        r/   test_legend_labelcolor_listr    s    llnGCGGBIIbM299R=?$G7GGBIIbM299R=?$G7GGBIIbM299R=?$G7
)))
/C3==?O< >ezz$$T^^%5u===>r1   c                  r   t        j                         \  } }|j                  t        j                  d      t        j                  d      dz  dd       |j                  t        j                  d      t        j                  d      dz  dd       |j                  t        j                  d      t        j                  d      d	z  d
d       |j                  d      }t        |j                         g d      D ]5  \  }}t        j                  j                  |j                         |      r5J  y )Nr   r   r  r   r   r-   ry   r  r   rz   r  r   	linecolorr  r  r  r  s        r/    test_legend_labelcolor_linecolorr    s    llnGCGGBIIbM299R=?$cGBGGBIIbM299R=?$cGBGGBIIbM299R=?$cGB
)){)
+C3==?O< >ezz$$T^^%5u===>r1   c                  r   t        j                         \  } }|j                  t        j                  d      t        j                  d      dz  dd       |j                  t        j                  d      t        j                  d      dz  dd       |j                  t        j                  d      t        j                  d      d	z  d
d       |j                  d      }t        |j                         g d      D ]5  \  }}t        j                  j                  |j                         |      r5J  y )Nr   r   r  r   r   markeredgecolorry   r  r   rz   r  r   r  r  r  r  r  s        r/   &test_legend_labelcolor_markeredgecolorr        llnGCGGBIIbM299R=?$GLGGBIIbM299R=?$GLGGBIIbM299R=?$GL
))0)
1C3==?O< >ezz$$T^^%5u===>r1   c                  r   t        j                         \  } }|j                  t        j                  d      t        j                  d      dz  dd       |j                  t        j                  d      t        j                  d      dz  dd       |j                  t        j                  d      t        j                  d      d	z  d
d       |j                  d      }t        |j                         g d      D ]5  \  }}t        j                  j                  |j                         |      r5J  y )Nr   r   r  r   r   markerfacecolorry   r  r   rz   r  r   r  r  r  r  r  s        r/   &test_legend_labelcolor_markerfacecolorr    r  r1   c                 p   t        j                         \  }}|j                  t        j                  d      t        j                  d      dz  d       |j                  t        j                  d      t        j                  d      dz  d       |j                  t        j                  d      t        j                  d      dz  d       | t
        j                  d	<   |j                         }|j                         D ]2  }t
        j                  j                  |j                         |       r2J  y )
Nr   r   r  r:   ry   r  rz   r  legend.labelcolor)r   r   r?   r   r>   r   r   r"   r  r(   r  r  r  s        r/   %test_legend_labelcolor_rcparam_singler    s     llnGCGGBIIbM299R=?$G7GGBIIbM299R=?$G7GGBIIbM299R=?$G7(-CLL$%
))+C >zz$$T^^%5u===>r1   c                     t        j                         \  } }|j                  t        j                  d      t        j                  d      dz  dd       |j                  t        j                  d      t        j                  d      dz  dd       |j                  t        j                  d      t        j                  d      d	z  d
d       dt
        j                  d<   |j                         }t        |j                         g d      D ]5  \  }}t
        j                  j                  |j                         |      r5J  y )Nr   r   r  r   r  ry   r  r   rz   r  r   r  r  r  r   r   r?   r   r>   r   r   r"   r   r  r(   r  r  r  s        r/   (test_legend_labelcolor_rcparam_linecolorr    s    llnGCGGBIIbM299R=?$cGBGGBIIbM299R=?$cGBGGBIIbM299R=?$cGB(3CLL$%
))+C3==?O< >ezz$$T^^%5u===>r1   c                     t        j                         \  } }|j                  t        j                  d      t        j                  d      dz  dd       |j                  t        j                  d      t        j                  d      dz  dd       |j                  t        j                  d      t        j                  d      d	z  d
d       dt
        j                  d<   |j                         }t        |j                         g d      D ]5  \  }}t
        j                  j                  |j                         |      r5J  y )Nr   r   r  r   r  ry   r  r   rz   r  r   r  r  r  r  r  s        r/   .test_legend_labelcolor_rcparam_markeredgecolorr        llnGCGGBIIbM299R=?$GLGGBIIbM299R=?$GLGGBIIbM299R=?$GL(9CLL$%
))+C3==?O< >ezz$$T^^%5u===>r1   c                     t        j                         \  } }|j                  t        j                  d      t        j                  d      dz  dd       |j                  t        j                  d      t        j                  d      dz  dd       |j                  t        j                  d      t        j                  d      d	z  d
d       dt
        j                  d<   |j                         }t        |j                         g d      D ]5  \  }}t
        j                  j                  |j                         |      r5J  y )Nr   r   r  r   r  ry   r  r   rz   r  r   mecr  r  r  r  s        r/   4test_legend_labelcolor_rcparam_markeredgecolor_shortr        llnGCGGBIIbM299R=?$GLGGBIIbM299R=?$GLGGBIIbM299R=?$GL(-CLL$%
))+C3==?O< >ezz$$T^^%5u===>r1   c                     t        j                         \  } }|j                  t        j                  d      t        j                  d      dz  dd       |j                  t        j                  d      t        j                  d      dz  dd       |j                  t        j                  d      t        j                  d      d	z  d
d       dt
        j                  d<   |j                         }t        |j                         g d      D ]5  \  }}t
        j                  j                  |j                         |      r5J  y )Nr   r   r  r   r  ry   r  r   rz   r  r   r  r  r  r  r  s        r/   .test_legend_labelcolor_rcparam_markerfacecolorr    r  r1   c                     t        j                         \  } }|j                  t        j                  d      t        j                  d      dz  dd       |j                  t        j                  d      t        j                  d      dz  dd       |j                  t        j                  d      t        j                  d      d	z  d
d       dt
        j                  d<   |j                         }t        |j                         g d      D ]5  \  }}t
        j                  j                  |j                         |      r5J  y )Nr   r   r  r   r  ry   r  r   rz   r  r   mfcr  r  r  r  s        r/   4test_legend_labelcolor_rcparam_markerfacecolor_shortr    r  r1   c                      t        j                         } | j                         rJ | j                  d       | j                         sJ | j                  d       | j                         rJ y )NTF)r   r"   get_draggableset_draggabler"   s    r/   test_get_set_draggabler  	  sb    ZZ\F##%%%
!!!
##%%%%r1   c                  ^   t        j                  g dddd      \  } }}t        j                         }|j                  D ]  }|j	                  d        j                         d d |d   j                         d d k(  sJ |j                         d d |d   j                         d d k(  sJ y )	Nrx   g      ?datarE  )rI  r   r-   rU   rF   r   )r   histr"   rm   	set_alphaget_facecolorget_edgecolor)r+   rO  hhr"   r{  s        r/   test_alpha_handlesr     s    xx	V5IHAq"ZZ\F"" 
Scr"be&9&9&;CR&@@@@cr"be&9&9&;CR&@@@@r1   c                 D   dt         j                  d<   dt         j                  d<   dt         j                  d<   t        j                         \  }}|j	                  ddd	       |j                  d
       |j                  j                          d| j                  vsJ y )Nr  zfont.familyzComputer Modernz
font.serifTztext.usetexr   inputr:   r   r  z Font family ['serif'] not found.)	r   r   r   r   r?   r"   r  r  r  )caplogr)   r*   s      r/   test_usetex_no_warnr    s{    ")CLL!2CLL"&CLLllnGCGGAqG IIKI JJOO-V[[@@@r1   c                     t        j                         \  } }| j                  j                          t	        d      D ](  }|j                  t        j                  d      |       * t        ddi      5  |j                         }d d d        t        j                  t              5 }| j                         d d d        t              dk(  sJ |D ]  }t        |j                         dk(  rJ  y # 1 sw Y   nxY w# 1 sw Y   GxY w)Nr^    r:   z
legend.locr<   ry   zGCreating legend with loc="best" can be slow with large amounts of data.)r   r   r  r  r   r?   r   r>   r   r"   ri   rj   rk   draw_artistrl   r
  r  )r)   r*   idxr"   recordsr  s         r/   test_warn_big_data_best_locr
  )  s    llnGCJJOOT{ ,
		$s+,	\6*	+ 	k	"  g  w<1  6>>"  	        s   5C3'C?3C<?Dc                     t        j                         \  } }| j                  j                          t	        d      D ](  }|j                  t        j                  d      |       * |j                  d      }| j                  |       y )Nr^  r  r:   r<   )
r   r   r  r  r   r?   r   r>   r"   r  )r)   r*   r  r"   s       r/   (test_no_warn_big_data_when_loc_specifiedr  ;  sd    llnGCJJOOT{ ,
		$s+,YYvFOOFr1   label_arraylowhigh)r  r  c                 
   g d}ddgddgddgg}t        j                         \  }}|j                  |||        |j                         }|j	                         D cg c]  }|j                          }}|dd	gk(  sJ y c c}w )
Nrx   r   ry   r   r\   	   r:   r  r  )r   r   r?   r"   r  r  )r  r+   r,   r)   r*   r   entrylegend_textss           r/   'test_plot_multiple_input_multiple_labelr  D  s     	A
Q
Q
Q	A llnGCGGAqG$
))+C25--/BENN$BLBE6?*** Cs   B r   r   r   c                     g d}ddgddgddgg}t        j                         \  }}|j                  |||        |j                         }|j	                         D cg c]  }|j                          }}|t        |       gdz  k(  sJ y c c}w )Nrx   r   ry   r   r\   r  r:   )r   r   r?   r"   r  r  r
  )r   r+   r,   r)   r*   r   r  r  s           r/   %test_plot_multiple_input_single_labelr  V  s     	A
Q
Q
Q	A llnGCGGAqG
))+C25--/BENN$BLBCJ<!++++ Cs   Bc                 $   g d}g d}t        j                         \  }}|j                  |||        |j                         }t	        |j                               dk(  sJ |j                         d   j                         t        |       k(  sJ y )Nrx   )ry   r   r   r:   r   r   )r   r   r?   r"   rl   r  r  r
  )r  r+   r,   r)   r*   r   s         r/   %test_plot_single_input_multiple_labelr  f  sz     	AAllnGCGGAqG$
))+Cs}}1$$$==?1&&(C,<<<<r1   c                      t        j                  t              5  g d} ddgddgddgg}g d}t        j                         \  }}|j                  | ||       d d d        y # 1 sw Y   y xY w)	Nrx   r   ry   r   r\   r  )r  r  mediumr:   )ri   r   r  r   r   r?   )r+   r,   r   r)   r*   s        r/   3test_plot_multiple_label_incorrect_length_exceptionr  u  sn     
z	" #VVV *,,.R
1E"# # #s   ?A""A+c                      t        j                         \  } }|j                  g dg dg dddd       |j                          y )Nr  rx   r{   r   faceFill)rC  r   r   )r   r   r   r"   rb   s     r/   test_legend_face_edgecolorr    s9    llnGCOOIy)!V6  CIIKr1   c                      t        j                         \  } }|j                  ddgddgd       |j                         }|j                  |u sJ |j                         d   j                  |u sJ y )Nr   ry   rz   r\   rS   r:   r   )r   r   r?   r"   r  r  r   s      r/   test_legend_text_axesr!    se    llnGCGGQFQF&G)
))+C88r>>==?1""b(((r1   c                  (   t        j                         \  } }|j                  ddgddgd       t        j                  dgdgd      g}|j                  |dgd      }|d   j                         |j                  d   j                         k(  sJ y )Nr   r   rT  )rB  r  r~  )r   r   r   mlinesLine2Dr"   
get_markerrm   )r)   r*   r.   r   s       r/   test_handlerline2dr&    s    llnGCJJ1v1vcJ*}}aS1#c23G
))Gj\Q)
7C1:  "c&7&7&:&E&E&GGGGr1   c                      t        j                         j                         } | j                         }|j	                  ddgddgd       | j                         }|j                  | u sJ y )Nr   r   rS   r:   )r   r_   
subfiguresr   r?   r"   )subfigr*   r   s      r/   test_subfigure_legendr*    sY    ZZ\$$&F		BGGQFQF&G)
--/C::r1   c                  ~   t        j                  ddgddgdd      } t        j                         j                         d   }|j	                  d       |j                         d d t        | j                         d   d d       k(  sJ |j                         d d t        | j                         d   d d       k(  sJ y )	Nr   r   ry   rz   z#123456r   )r-   r   r   )r   r   r"   get_patchesr  r  tupler  )pcr   s     r/   -test_setting_alpha_keeps_polycollection_colorr/    s    			1a&1a&		IBJJL$$&q)E	OOC !$b.>.>.@.CBQ.G(HHHH !$b.>.>.@.CBQ.G(HHHHr1   c            	         g d} t        j                         \  }}| D cg c]  }t        j                  dgdgd|       }}g d}|D cg c]  }|j	                          }}|j                  ||      }|j                         D cg c]  }|j	                          }	}|j                         D 
cg c]  }
|
j                          }}
||	cxk(  r| k(  sJ  J ||k(  sJ y c c}w c c}w c c}w c c}
w )N).*rT  r   None)lsrB  )r<  rI   xyzzy)	r   r   r#  r$  r%  r"   	get_linesr  r  )_markersr)   r*   markr   r'   rS   markersr"   new_markersr  
new_labelss               r/   test_legend_markers_from_line2dr<    s    HllnGC!# ]]A3t< #E #$F-23Tt 3G3YYuf%F171A1A1CD4??$DKD.4.>.>.@Ad$--/AJAk-X-----Z# 4 EAs   "C%C*	C/4C4c                 \    g d}d}| j                  ||       |j                  ||       y )N)r   r   r   rr   er  rz   )ncol)r   r  )fig_testfig_refstringsr   s       r/   test_ncol_ncolsrC    s.     -GEOOG%O(NN7%N(r1   )er    platformunittestr   r  numpyr   ri   matplotlib.testing.decoratorsr   r   matplotlib.testing._markersr   matplotlib.pyplotpyplotr   
matplotlibr   matplotlib.transforms
transformsr`  matplotlib.collectionsrm  matplotlib.linesr   r#  matplotlib.legend_handlerr   matplotlib.legendr"   rU  r   matplotlib.font_managerr	   r0   r@   rL   rX   rc   rn   rv   r   machiner   r   r   r   r   r   r   r   r   r  r:  r@  rQ  rY  r[  re  r|  r  r  r  r  r  r  r  r  r8  parametrizer  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r
  r  arrayr  intr  r  r  r  r!  r&  r*  r/  r<  rC  r   r1   r/   <module>rW     s         O 4   + - ! 2 # ! 29$ >"5 6 >"5: 6: >"# $ *+>' ?'* ,-4@- A- -.DA	I B	I #$$+8++-9atE2E2 &'T+8++-9atE	6E	6 7).E /E <.d+8++-9atEE =-0dC! D!  ?#68 78 :,D	B. C.@#]N ]N@= =@ )*+ ,( -./" 0" 789+ :+:(' ,-,#1L &AB, C, &AB, C, "?@	> A	>	>	>	>	> "?@
> A
>
>
>
>
>
>&A 
A 
A $ %)8)15&/)B)D E+E+ 5!S/2, 3, %)8)15&/)B)D E	=E	=
#)H I " ) )r1   