Files
intellecton/venv/lib/python3.12/site-packages/matplotlib/__pycache__/contour.cpython-312.pyc
T

874 lines
77 KiB
Plaintext
Raw Normal View History

Ë
†Rj ãó(dZddlmZddlZddlZddlmZddlZddlm Z ddl
Z ddl
m Z m
Z
ddlmZddlmZdd lmZdd
lmZddlmZddlmZddlmZddlmZddl m!Z!ddl"m#Z#ddl$m%Z&ddl'm(Z)d Z*Gd d
«Z+dZ,e
jZj]d¬«e
jZGdde+ej^««Z0e
jZGdde0««Z1e
jZj]de
jZjdz¬«y)zG
Classes to support contour plotting and labelling for the Axes class.
é)Ú ExitStackN)ÚIntegral)Úma)Ú_apiÚ
_docstring)Ú MouseButton)ÚLine2D)ÚPath)ÚTextcóÂ|jjd¬«j}|jdk(}|jdk(}|r|jt
j k(s|r|jdvr|j«y|r|jt
jk(s|r2|jdvr$|s!|j«|j«yy|r|jt
jk(s|rg|jZ|jj|«dr;|j|j|j d||¬ «|j«yyyy)
NT©ÚrootÚbutton_press_eventÚkey_press_event)ÚescapeÚenter)Ú backspaceÚdeleterF)Ú transformÚinlineÚinline_spacing)ÚaxesÚ
get_figureÚcanvasÚnameÚbuttonrÚMIDDLEÚkeyÚstop_event_loopÚRIGHTÚ pop_labelÚdrawÚLEFTÚcontainsÚadd_label_nearÚy)ÚcsrrÚeventrÚ is_buttonÚis_keys úU/home/antigravity/intellecton/venv/lib/python3.12/site-packages/matplotlib/contour.pyÚ_contour_labeler_event_handlerr-s"Ø
W‰W×
Ñ
 
Ó
*×
1€FØ
Ð2€IØ
Z‰ZÐ
,€Fñ e—ll¤k×&8Ñ&8Ò˜%Ÿ)™)Ð':Ñ×ÑÕ á
˜Ÿ ¬ ×(9Ñ(9Ò
˜Ÿ ™ Ð%<ÑØ L‰LŒNØ K‰Kñ ˜Ÿ ¬ ×(8Ñ(8Ò
˜Ÿ ™ Ð
7‰7× Ñ ˜ "  × Ñ ˜eŸg™g u§w¡w¸%Ø%+¸
ô
Là K‰K .ˆc ó†eZdZdZdddddddddddœ dZdZd „Zd
Zd Zd Z dd
Z
dZ ddZ ddZ
dZˆfdZˆxZS)ÚContourLabelerz7Mixin to provide labelling capability to `.ContourSet`.NTéF) ÚfontsizerrÚfmtÚcolorsÚuse_clabeltextÚmanualÚ rightside_upÚzorderc óÜ|€&tjd¬«}|j«||_||_||_| |_|
d|j«zn|
|_|€4|j}ttt|j«««} n…t|«} gg}} t|j«D],\}
}|| vsŒ | j|
«|j|«Œ.t|«t| «krt!d| d|j«||_| |_t'j(|¬«|_|€7||_t/j0|j|j$«|_n„t5j6|t|j"«¬«}ttt|j"«««|_t9j:|t5j<«¬«|_g|_t/j@|«r|D]\}}|jC||||«Œn|r}tEd «tEd
«|s tEd «tFjHjK|jLjOd ¬
«ddgdtQjRtT|||«¬«n|jW||«tYjZd|j\«S)a|
Label a contour plot.
Adds labels to line contours in this `.ContourSet` (which inherits from
this mixin class).
Parameters
----------
levels : array-like, optional
A list of level values, that should be labeled. The list must be
a subset of ``cs.levels``. If not given, all levels are labeled.
fontsize : str or float, default: :rc:`font.size`
Size in points or relative size e.g., 'smaller', 'x-large'.
See `.Text.set_size` for accepted string values.
colors : :mpltype:`color` or colors or None, default: None
The label colors:
- If *None*, the color of each label matches the color of
the corresponding contour.
- If one string color, e.g., *colors* = 'r' or *colors* =
'red', all labels will be plotted in this color.
- If a tuple of colors (string, float, RGB, etc), different labels
will be plotted in different colors in the order specified.
inline : bool, default: True
If ``True`` the underlying contour is removed where the label is
placed.
inline_spacing : float, default: 5
Space in pixels to leave on each side of label when placing inline.
This spacing will be exact for labels at locations where the
contour is straight, less so for labels on curved contours.
fmt : `.Formatter` or str or callable or dict, optional
How the levels are formatted:
- If a `.Formatter`, it is used to format all levels at once, using
its `.Formatter.format_ticks` method.
- If a str, it is interpreted as a %-style format string.
- If a callable, it is called with one level at a time and should
return the corresponding label.
- If a dict, it should directly map levels to labels.
The default is to use a standard `.ScalarFormatter`.
manual : bool or iterable, default: False
If ``True``, contour labels will be placed manually using
mouse clicks. Click the first button near a contour to
add a label, click the second button (or potentially both
mouse buttons at once) to finish adding labels. The third
button can be used to remove the last label added, but
only if labels are not inline. Alternatively, the keyboard
can be used to select label locations (enter to end label
placement, delete or backspace act like the third mouse button,
and any other key will select a label location).
*manual* can also be an iterable object of (x, y) tuples.
Contour labels will be created as if mouse is clicked at each
(x, y) position.
rightside_up : bool, default: True
If ``True``, label rotations will always be plus
or minus 90 degrees from level.
use_clabeltext : bool, default: False
If ``True``, use `.Text.set_transform_rotates_text` to ensure that
label rotation is updated whenever the Axes aspect changes.
zorder : float or None, default: ``(2 + contour.get_zorder())``
zorder of the contour labels.
Returns
-------
labels
A list of `.Text` instances for the labels.
F)Ú useOffsetézSpecified levels z don't match available levels )Úsize©ÚN)ÚcmapÚnormz9Select label locations manually using first mouse button.z.End manual selection with second mouse button.z1Remove last label by clicking third mouse button.Tr
rréÿÿÿÿ)ÚtimeoutÚhandlerz text.Text)/ÚtickerÚScalarFormatterÚcreate_dummy_axisÚlabelFmtÚ_use_clabeltextÚ labelManualr7Ú
get_zorderÚ_clabel_zorderÚlevelsÚlistÚrangeÚlenÚcvaluesÚ enumerateÚappendÚ
ValueErrorÚlabelLevelListÚlabelIndiceListÚ font_managerÚFontPropertiesÚ_label_font_propsÚ
labelMappableÚnpÚtakeÚlabelCValueListÚmcolorsÚListedColormapÚcmÚScalarMappableÚNoNormÚlabelXYsÚiterabler%ÚprintÚmplÚ_blocking_inputÚblocking_input_looprrÚ functoolsÚpartialr-ÚlabelsÚcbookÚ silent_listÚ
labelTexts)ÚselfrLr2rrr3r4r5r6r7r8ÚindicesÚlevlabsÚlevr?r&r's r,ÚclabelzContourLabeler.clabel=ð| ˆ×(°5Ô9ˆCØ × ˆŒ
ØÔØÔØÔØ7=°~˜a $§/¡/Ó"3Ò3È6ˆÔà ˆ—[‘[ˆFÜœ5¤ T§\¡\Ó!2Ó4‰Gä˜6“lˆ  "Vˆ# D§K¡KÓ
'˜'—NN —MM 
6{œS  Ð#4°W°Ið>5Ø59·[±[°Mð"CóDðDà$ˆÔØ&ˆÔä!-×!<Ñ!<À(Ô!KˆÔà ˆ>Ø!%ˆ Ü#%§7¡7¨4¯<©<¸×9MÑ9MÓ#Nˆ ä×)¨&´C¸×8KÑ8KÓ4LÔMˆDÜ#'¬¬c°$×2EÑ2EÓ.FÓ(GÓ#Hˆ Ü!#×!2Ñ!2¸Ü8?¿¹Ó8Hô"Jˆ ðˆŒ
ä
;‰; Øò
B×# A q¨&°.Õ
Bá
Ü Ð Ð ÜÐ × Ñ × — ‘ ×$¨$Ð%Ð'8ФI×$5Ñ$5ܘ& %2ð


K‰K˜ Ô × Ñ  ¨d¯o©oÓ>r.có˜t|«d|zkDxs8t|«xr+tj|d¬«d|zkDj«S)z8Return whether a contour is long enough to hold a label.é
r©Úaxisç333333ó?)rOrZÚptpÚany)rnÚ linecontourÚ
labelwidths r,Ú print_labelzContourLabeler.print_labelÔsNä  
¡?ÑPܘ ÓOÜŸ  °!Ô4°s¸ZÑ7GÑG× Qr.cóXd|zdzŠtˆˆˆfd|jD««S)z5Return whether a label is already near this location.rxr;c3óRK|]}|dz
dz|dz
dzzkŒ y­w)rr;é)Ú.0ÚlocÚthreshr&r's €€€r,ú <genexpr>z+ContourLabeler.too_close.<locals>.<genexpr>Ýs=øèø€òð˜˜A™‘J 1ѨC°©F©
°qÑ'8Ñ8¸-ùsƒ$')rzrb)rnr&r'Úlwr„s `` @r,Ú too_closezContourLabeler.too_closeÚs.ú€à˜‘(˜q‘ˆÜõ"Ÿm™mô -r.có.|jjd¬«}|jd¬«j«}tdd|j |j
||j «||j¬«j|«jS)z/Return the width of the *nth* label, in pixels.Fr
Tr)ÚfigureÚfontproperties)
rrÚ
_get_rendererr Úget_textrTrGrXÚget_window_extentÚwidth)rnÚnthÚfigÚrenderers r,Ú_get_nth_label_widthz#ContourLabeler._get_nth_label_widthàs}ài‰i×Ð.ˆØ—>> t,×<ˆÜQ˜Ø—]] 4×#6Ñ#6°sÑ#;¸T¿]¹]Ó°×0FÑ0FôH÷" ,¯U©Uð 4r.có
t|t«r|St|t«r|j|d«St t |dd««r"|j
g|j¢|«dSt |«r||«S||zS)zGet the text of the label.z%1.3fÚ format_ticksNrA)Ú
isinstanceÚstrÚdictÚgetÚcallableÚgetattrr”rT)rnrrr3s r,zContourLabeler.get_textés~ä cœ3Ô ØˆJÜ
˜œTÔ
—77˜3 Ó
”g˜c >°4Ó
×#Ð$? d×&9Ñ&9Ð$?¸3Ð$?ÓÑ
cŒ]Ùs“8ˆ˜ r.có,t|«}|dkDr!ttj||z ««nd}|dk(r|n
t|«}tj|dddf||f«}tj|dddf||f«}|ddddf}|ddddf} |ddddf}
|ddddf} ||z
| |
z
z|
|z
| |z
zz
} tj
| |
z
| |z
«}
tj dd¬«5t| «|
z jd¬«}ddd«|dz}tj«}tj||d«D]%}|||f|||f}}|j|||«rŒ%n|z|z|zfS#1swYŒrxYw) zX
Find good place to draw a label (relatively flat part of the contour).
r€NrrAÚignore)ÚdivideÚinvalidrvr;) rOÚintrZÚceilÚresizeÚhypotÚerrstateÚabsÚsumÚargsortrRr‡)rnr{r|Úctr_sizeÚn_blocksÚ
block_sizeÚxxÚyyÚyfirstÚylastÚxfirstÚxlastÚlÚ distancesÚhbsizeÚadistÚidxr&r's r,Ú locate_labelzContourLabeler.locate_labelöôØ:DÀqº.”3”r—w‘w˜x¨*Ñ6ÈaˆØ!)¨Q¢‘X´C¸
³Oˆ
ôY‰Y{¢1 a (¨8°ZÐ*@Ó
AˆÜ
Y‰Y{¢1 a (¨8°ZÐ*@Ó
Ø’ArE‘ˆØ’1bc6
ˆØ’ArE‘ˆØ’1bc6
ˆØ
b‰[˜U V™^Ñ ¸± ÀÈÁÑ/OÑ Ü H‰HU˜V^ U¨V¡^Ó 4ˆä
[‰[ °(Ô
˜Q› !™×(¨bÐ1ˆI÷
˜qˆÜ
˜9Óô—9‘9˜U E¨!¡HÓ ˆc˜6k? B s¨F {¡Oˆqˆ—>> ! 
Õð ð!c˜Ñ/°8Ñ 2ús Ã:F
Æ
Fc
óx|j}|j}|j«j«j |«}t j |||«s>t j|||d¬«}t j||tj«}|tjk(j«d} | | |kd}
| | |kDd} ||
| } ||
z}|| dz
tjk(}
|
r"t j| |d| d|dzg«} d}d}|j«j | «}t jt j t j"t j$|d¬«j&Ž«dd«}|||z}t j(| dz |dz g«}|
r|dxx|d|dz
z
cc<||||«\\}}\}}t j*t j,||z
||z
««}|j.r |dzd zdz
}|| |­gz
}t j0||t3t|««dd¬
«\}}t5j6|«}t5j8|«}|||| «\\}}\}}g}g}|
rq|dk7r!|dk7r| ||dz}|j;||fg|||fgg«t|«dz} |j;tjgtjg| zg«n¶|dk7rS|j;| d|dz||fgg«|j;tjgtjg|dzzg«|dk7rY|j;||fg| |dg«|j;tjgtjgt| «|z
zg«t j|d|
g|¢|| d«}t j|d|
g|¢|| d«}|t||«fS#t$rt|«} YŒ`wxYw) 
Prepare for insertion of a label at index *idx* of *path*.
Parameters
----------
path : Path
The path where the label will be inserted, in data space.
idx : int
The vertex index after which the label will be inserted.
screen_pos : (float, float)
The position where the label will be inserted, in screen space.
lw : float
The label width, in screen space.
spacing : float
Extra spacing around the label, in screen space.
Returns
-------
path : Path
The path, broken so that the label can be drawn over it.
angle : float
The rotation of the label.
Notes
-----
Both tasks are done together to avoid calculating path lengths multiple times,
which is relatively costly.
The method used here involves computing the path length along the contour in
pixel coordinates and then looking (label width / 2) away from central point to
determine rotation and then to break contour if desired. The extra spacing is
taken into account when breaking the path, but not when computing the angle.
rrvrAr€Ncój|jDcgc]}tj|||«Œc}Scc}w©N)ÚTrZÚinterp)r&ÚxpÚfpÚcols r,Ú
interp_veczEContourLabeler._split_path_and_get_label_rotation.<locals>.interp_vec]s&ÈBÏDÉDÖ*QÀS¬2¯9©9°Q¸¸CÕ+@Ò*QÐ#QùÒ*Qs0r;éZé´)ÚleftÚright)ÚverticesÚcodesÚ
get_transformÚinvertedrrZÚallcloseÚinsertr
ÚLINETOÚMOVETOÚnonzeroÚ
IndexErrorrOÚ CLOSEPOLYÚ concatenateÚcumsumr¢ÚdiffrºÚarrayÚrad2degÚarctan2r7rNÚmathÚfloorr Úextend)!rnÚpathrµÚ
screen_posr†ÚspacingÚxysrÅÚposÚmovetosÚstartÚstopÚcc_xysÚis_closed_pathr¿Ú
screen_xysÚ path_cplsÚ target_cplsÚsx0Úsx1Úsy0Úsy1ÚangleÚi0Úi1Úx0Úx1Úy0Úy1Ú
new_xy_blocksÚnew_code_blocksÚpointsÚnliness! r,Ú"_split_path_and_get_label_rotationz1ContourLabeler._split_path_and_get_label_rotations-ðDm‰mˆØ
ˆð× Ñ Ó-×7¸
ÓÜ{‰{˜3  C¡Ô—)‘)˜C  c°Ô2ˆCÜ—I‘I˜e S¬$¯+©+Ó6ˆEð
œDŸK™KÑ'×2°1Ñ5ˆØ˜ 3™ÑÑð Ø˜7 S™=Ñ)¨!Ñ,ˆ
U˜4ˆØ ˆu‰ ˆð˜t a™x™¬D¯N©NÑÙ Ü—^‘^ V¨C° ^°V¸F¸SÀ¹U°^Ð$DÓEˆF؈ Rð×)×3°FÓ;ˆ
Ü—I‘IÜ I‰I”b—h‘h¤§¡¨
¸Ô ;× =Ñ =Ð ÀAóGˆ àY˜s‘^Ñ#ˆ ô—h‘h   A¡ r¨!¡t˜}Ó Ù Ø ˜‹N˜y¨™}¨y¸©|Ñ <NÙ!+¨K¸ÀJÓ!OÑ
ˆˆcJS˜
œ2Ÿ:™: c¨C¡i°°s±ÓØ × Ò Ø˜RZ 3ÑÑ+ˆ˜˜ 7 (Ð ô˜;¨ ´5¼¸Ó3HØ "¨"ô.‰ˆˆ
Z‰Z˜^ˆÜ
Y‰Yr]ˆÙ °YÀÓˆˆR‘(2ˆ
؈٠ØRx˜B "   2 a¡4˜Ø×¨B x j°&¸¸8¸*Ð%EÔ˜V q™Ø×¯©¨
¼¿ ¹ °}ÀvÑ7MÐ'NÕRŠxØ×$ f¨W¨b°1©f o¸¸R¸°zÐ%BÔׯ©¨
¼¿ ¹ °}ÈÈQÉÑ7OÐ'PÔRŠxØ×¨B x j°&¸¸°+Ð%>Ô×—[[M¤D§K¡K =´C¸³KÀ"Ñ4DÑ#Eð(GôHôn‰n˜c & 5˜F¨MÐF¸3¸t¸u¸:ÐÜ  f u 
ÐÐÀtÀuÀÐà”d˜3 Ó&øôCò Üu“:‹Dð úsÃ
P!Ð!P9Ð8P9có|jjj«j||f«\}}t |||j ||j «|dd|j|jj||j«¬«|j|jj¬«
}|jrM|jjj«j|g||gg«\} |j| d¬«|j j#|«|j$j#|«|j&j#||f«|jj)|«y)zAAdd a contour label, respecting whether *use_clabeltext* was set.Úcenter)Úalpha)ÚtextÚrotationÚhorizontalalignmentÚverticalalignmentr8ÚcolorrŠÚclip_boxT)Útransform_rotates_textN)rÚ transDatarÇrr rGrKrYÚto_rgbaÚ get_alpharXÚbboxrHÚtransform_anglesÚsetrmrRÚ labelCValuesrbÚ
add_artist)
rnr&r'rrÚcvalueÚdata_xÚdata_yÚ
data_rotations
r,Ú add_labelzContourLabeler.add_labels.àŸ×7×AÀ1ÀaÀ&ÓI‰ˆÜ Ø ˜s D§M¡MÓØ (¸××$×,¨V¸4¿>¹>Ó;KÐ×—Y‘Y—^‘^ô
ð × Ò Ø!ŸY™Y×;×
˜a ˜V˜&‰Nˆ
E‰E˜=ÀˆEÔ  ×јqÔ ×Ñ× Ñ  Ô
×јa ˜VÔ ‰ ×јQÕr.cóB||jj}|rL|jj|«}|jj|«}|j ||f«\}}|j ||f|j «\}}}|j|} |j j|«}
|j|
«} |j| ||| |«\} } |jg|¢| |j||j|­Ž|r| |j|<yy)a†
Add a label near the point ``(x, y)``.
Parameters
----------
x, y : float
The approximate location of the label.
inline : bool, default: True
If *True* remove the segment of the contour beneath the label.
inline_spacing : int, default: 5
Space in pixels to leave on each side of label when placing
inline. This spacing will be exact for labels at locations where
the contour is straight, less so for labels on curved contours.
transform : `.Transform` or `False`, default: ``self.axes.transData``
A transform applied to ``(x, y)`` before labeling. The default
causes ``(x, y)`` to be interpreted as data coordinates. `False`
is a synonym for `.IdentityTransform`; i.e. ``(x, y)`` should be
interpreted as display coordinates.
N)rrÿÚconvert_xunitsÚconvert_yunitsrÚ_find_nearest_contourrUÚ_pathsÚindexrr rTr\)
rnr&r'rrrÚ
idx_level_minÚ idx_vtx_minÚprojrØÚlevelÚ label_widthrùs
r,r%zContourLabeler.add_label_near¨s/ð, Ð ØŸ ™ ×+ˆIÙ Ø— ‘ ×Ó+ˆAØ— ‘ ×Ó+ˆ×¨1 .‰DˆAˆqà+/×+EÑ+EØ
ˆFD×,*Ñ(ˆ
{ Dà{‰{˜=ÑØ×*¨=ÓØ×Ó Ø× +˜t [°.óBˆˆð <˜ð <˜×(;Ñ(;¸MÑ(Jð×+¨MÑ Ø)-ˆDK‰K˜
Ò  r.có|jj|«|jj|«}|j«y)z>Defaults to removing last label, but any index can be suppliedN)rÚpoprmÚremove)rnrr
s r,r!zContourLabeler.pop_labelÒs3à ×Ñ×јeÔ O‰O× Ñ  Ó &ˆØ 
r.c ó†tt|j|j|j««D] \}\}}}|j «}|j
|«}g} |j|j«D}
|j|
j«} |j| |«rZ|j| |«\} }
}|j|
|| |
f||«\}}|j| |
|||«|sŒx| j|«ŒŠ| j|
«Œœ|sŒët!j"| Ž|j|<Œ y)rQÚziprUrTr\rrÚ_iter_connected_componentsrr}r rRr
Úmake_compound_path)rnrrÚiconrrrÚtransrÚ additionsÚsubpathrâr&r's r,rjzContourLabeler.labelsØs?Ü(1´×××3
ó) ó HÑ $ˆ$$˜˜
×(ˆ×3°CÓ8ˆK؈IØŸ;™; tÑ
.Ø"Ÿ_™_¨W×-=Ñ-=Ó>
à×#  Ô<Ø $× 1Ñ 1°*¸kÓ JIAq˜#Ø%)×%LÑ%LØ  q¨! # &5NH˜—NN 1 °3¸ÔØÕ×$ WÕ
Ü$(×$;Ñ$;¸YÐ$G ˜!ñ1 Hr.códt|«|jD]}|j«Œy)Úsuperrrm)rnÚ __class__s €r,rzContourLabeler.removeós)ø€Ü
ÔØ—O‘Oò ˆDØ K‰K r.)r1)Tr1N)rA)Ú__name__Ú
__module__Ú __qualname__Ú__doc__rsr}r‡rr r%r!rjrÚ
__classcell__©r%s@r,r0r0:stø„ÙU T¸!Àب5¸Ø ¨ôU?ònQò   ò <óDx'òt ð,@AØ!%ó(.óTò H÷6ðr.r0có°t|«dk(r||dz
dzj«|ddfS|dd|ddz
}|dzjd¬«}d||dk(<tj||ddz
|zjd¬«|z dd«dddf}|dd||zz}||z
dzjd¬«}tj|«}||||||dzffS)a
Parameters
----------
xys : (N, 2) array-like
Coordinates of vertices.
p : (float, float)
Coordinates of point.
Returns
-------
d2min : float
Minimum square distance of *p* to *xys*.
proj : (float, float)
Projection of *p* onto *xys*.
imin : (int, int)
Consecutive indices of vertices of segment in *xys* where *proj* is.
Segments are considered as including their end-points; i.e. if the
closest point on the path is a node in *xys* with index *i*, this
returns ``(i-1, i)``. For the special case where *xys* is a single
point, this returns ``(0, 0)``.
r€rr;©rrNrArv)rOrZÚclipÚargmin)ÚdxysÚnormsÚ rel_projsÚprojsÚd2sÚimins r,Ú_find_closest_point_on_pathr7ùsô, ˆ3ƒx1c˜!f* Ñ"×)¨3¨q©6°6Ð ˆqˆrˆ7S˜˜" €DØ
Q‰YO‰O ˆ #€EØ€Eˆ%1‰*ÑÜØ
ˆc#2ˆh‰,˜$Ñ ×Ð+¨eÑ ˆ1óâˆgñ€Ið
ˆHy  '€EØ A‰I˜ ×
Ñ
 
Ó
(€CÜ
9‰9S>€DØ ‰Iu˜T{ T¨4°©6  3r.
Attributes
----------
levels : array
The values of the contour levels.
layers : array
Same as levels for line contours; half-way between
levels for filled contours. See ``ContourSet._process_colors``.
)Úcontour_set_attributescó
eZdZdZddddddddddddddddddddddœˆfd
Zed „«Zed
«Zed «Zed «Z d
Z
dZ de fdZ
dZdZdZˆfdZdZdZdZdZdZdZddZddZˆfdZˆxZS)Ú
ContourSeta¹
Store a set of contour lines or filled regions.
User-callable method: `~.Axes.clabel`
Parameters
----------
ax : `~matplotlib.axes.Axes`
levels : [level0, level1, ..., leveln]
A list of floating point numbers indicating the contour levels.
allsegs : [level0segs, level1segs, ...]
List of all the polygon segments for all the *levels*.
For contour lines ``len(allsegs) == len(levels)``, and for
filled contour regions ``len(allsegs) = len(levels)-1``. The lists
should look like ::
level0segs = [polygon0, polygon1, ...]
polygon0 = [[x0, y0], [x1, y1], ...]
allkinds : ``None`` or [level0kinds, level1kinds, ...]
Optional list of all the polygon vertex kinds (code types), as
described and used in Path. This is used to allow multiply-
connected paths such as holes within filled polygons.
If not ``None``, ``len(allkinds) == len(allsegs)``. The lists
should look like ::
level0kinds = [polygon0kinds, ...]
polygon0kinds = [vertexcode0, vertexcode1, ...]
If *allkinds* is not ``None``, usually all polygons for a
particular contour level are grouped together so that
``level0segs = [polygon0]`` and ``level0kinds = [polygon0kinds]``.
**kwargs
Keyword arguments are as described in the docstring of
`~.Axes.contour`.
%(contour_set_attributes)s
NFr¹Úneitherr)rLÚfilledÚ
linewidthsÚ
linestylesÚhatchesr÷ÚoriginÚextentr?r4r@ÚvminÚvmaxÚ colorizerr×Ú antialiasedÚnchunkÚlocatorrÚnegative_linestylesÚ clip_pathc ó„ ||rd}t‰ ||||||¬«||_||_||_||_||_| |_| |_||_ ||_
||_ |r/|j||
| |
|| ¬«|j} |j}
t| t j"«s$t|jt$j&«rd|_| t!j"«} nd|_t+j,gd¢|¬«|j#t/|j«dk7r t1d «|j
|
t1d
«|j d k(rt2j4d |_||_||_|j8t2j4d
|_|j:|i|¤Ž}|j=«|jdv|_|jdv|_ |j#t!jB|j«r|jg}n |j}t/|j«}|jr|dz}d}d}|tE|j>«ztE|j@«z}t/|«|k(r(|j>s |j@rd}|j>rd}t!jF||d|¬«}
|r@|j>r|
jI|d«|j@r|
jK|d«g|_&g|_'|jQ|
«| |jS| «|jjTjWd¬«5|
|
|j_,|||j_-ddd«|jj]«|j_«|j`|jc«|_0|jrN|t+jdd«|jg«\}}|jid|jkdd«¬«nD|jid|jm|«|jo|«|jkdd«d¬«|jjq|d¬«|jrd|jtdg|jvjxdd|jrd|jtdg|jvjzdd|jj}|jr|jtg«|jjd¬«|j«|r6t+jddd jƒt…t†|««z«yy#1swYŒxYw)!aÂ
Draw contour lines or filled regions, depending on
whether keyword arg *filled* is ``False`` (default) or ``True``.
Call signature::
ContourSet(ax, levels, allsegs, [allkinds], **kwargs)
Parameters
----------
ax : `~matplotlib.axes.Axes`
The `~.axes.Axes` object to draw on.
levels : [level0, level1, ..., leveln]
A list of floating point numbers indicating the contour
levels.
allsegs : [level0segs, level1segs, ...]
List of all the polygon segments for all the *levels*.
For contour lines ``len(allsegs) == len(levels)``, and for
filled contour regions ``len(allsegs) = len(levels)-1``. The lists
should look like ::
level0segs = [polygon0, polygon1, ...]
polygon0 = [[x0, y0], [x1, y1], ...]
allkinds : [level0kinds, level1kinds, ...], optional
Optional list of all the polygon vertex kinds (code types), as
described and used in Path. This is used to allow multiply-
connected paths such as holes within filled polygons.
If not ``None``, ``len(allkinds) == len(allsegs)``. The lists
should look like ::
level0kinds = [polygon0kinds, ...]
polygon0kinds = [vertexcode0, vertexcode1, ...]
If *allkinds* is not ``None``, usually all polygons for a
particular contour level are grouped together so that
``level0segs = [polygon0]`` and ``level0kinds = [polygon0kinds]``.
**kwargs
Keyword arguments are as described in the docstring of
`~.Axes.contour`.
NF)Ú antialiasedsr÷rIrrD)r?r@rBrCr4T)lowerÚupperÚimage)r@éz3If given, 'extent' must be None or (x0, x1, y0, y1)z"Either colors or cmap must be NonerNz image.originzcontour.negative_linestyle©ÚminÚboth©ÚmaxrRr€rr=rAÚchanged)Úsignalz!linewidths is ignored by contourfÚnoner8)Ú edgecolorr8r;Ú
_nolegend_)Ú facecolorr=Ú linestyler8Úlabel)Úautolim)Útightz/The following kwargs were not used by contour: z, )Dr$Ú__init__rrLr<r?r@rAr4r×rFrGÚ_set_colorizer_check_keywordsr@r?r•r]ÚLogNormrDÚ
LogLocatorÚlogscalerÚ
check_in_listrOrSreÚrcParamsÚ_orig_linestylesrHÚ
_process_argsÚ_process_levelsÚ _extend_minÚ _extend_maxÚ
is_color_likerŸr^Ú set_underÚset_overrmrÚset_cmapÚset_normÚ callbacksÚblockedrBrCÚ_changedÚ_process_colorsrÚ"_make_paths_from_contour_generatorÚ
warn_externalÚ_get_lowers_and_uppersrrÚ_process_linewidthsÚ_process_linestylesÚadd_collectionÚ_minsÚ_maxsÚ sticky_edgesr&r'Úupdate_datalimÚautoscale_viewrUÚjoinÚmapÚrepr)!rnÚaxrLr<r=r>r?r@rAr?r4r@rBrCrDr×rErFrGrrHrIÚargsÚkwargsÚcolor_sequenceÚncolorsrêÚuse_set_under_overÚ total_levelsÚlowersÚuppersr%s! €r,r_zContourSet.__init__Usø€ðf Ð ¡6àˆKô ÑØØØØð ô
ðˆŒ ØˆŒ ؈Œ ؈Œ ؈Œ ؈Œ ؈Œ ؈Œ àˆŒ ؈Œ á Ø × .¨y¸tØ48¸tØ48Àð

Ið—>>ˆ—>>ˆ tœWŸ_™_Ô ˜dŸl™l¬F×,=Ñ,=Ô ˆDŒM؈|ÜÓ(‘à!ˆDŒMä ×ÑÒ<ÀVÕ ;‰;Ð "¤s¨4¯;©;Ó'7¸1Ò'<ÜØGð
Gà ;‰;Ð " tÐ'7ÜÐ ;‰;˜ Ÿ,™, 6ˆDŒKà *ˆÔØ#6ˆÔ ð ×  Ð
Ô $×# TÐ4¨VÑØ ×ÑÔàŸ;™;¨/ÐÔØŸ;™;¨/ÐÔØ ;‰;Ñ ×$ T§[¡[Ô1Ø"&§+¡+ à!%§¡ä˜$Ÿ+™+Ó&ˆGØ{Š{ؘ1 ؈Bð
"'Ð ð
 × 0Ñ 0Ó × 0Ñ 0Ó2ˆLô# |Ò××)9Ò)9Ø%)Ð××)¨.¸¸DÐ*AÀWÔMˆDá×—NN >°!Ñ#4Ô×—MM Ñ"4ÔˆŒØˆÔà
Ø Ð Ø M‰M˜$Ô Ø
Y‰Y×
Ñ
×
(° Ð
ÐØ!%ØÐØ!%÷ 
‰ ×ÑÔØ ×ÑÔà ;‰;Ð Ø×CˆDŒKà ;Š;ØÐ×"Ð#FÔ!×:‰NˆF H‰HØ à—zz (¨AÓ
õ
ð
H‰HØ Ø×3°JÓ×2°:Ó—zz (¨AÓ
ô
ð
‰ × Ñ  ¨uÐ Ô5Ø"&§*¡*¨Q¡-°·±¸A±Ð!?ˆ×Ñ×Ñ™AÐØ"&§*¡*¨Q¡-°·±¸A±Ð!?ˆ×Ñ×Ñ™AÐØ ‰ × Ñ  $§*¡*¨d¯j©jÐ!9Ô ‰ × Ñ  tÐ Ô Œá Ü × Ñ Ø— ‘ œ#œd FÓ
ð ÷S &ús Î'V5Ö5V?có¤|j«Dcgc]*}|j«Dcgc]}|jŒc}Œ,c}}Scc}wcc}}w)Ú get_pathsr©rnr0Úsubps r,ú<lambda>zContourSet.<lambda>sAàÓ%#à
ð$%×#?Ñ#?Ó#AÖB˜4ˆÔ%#€ùÚBùó%#óA «A ¾A ÁA có¤|j«Dcgc]*}|j«Dcgc]}|jŒc}Œ,c}}Scc}wcc}}w)rrs r,rzContourSet.<lambda>!sAàÓ&#à
ð!"× <Ñ <Ó >Ö?˜ˆÔ&#€ùÚ?ùó&#rcó"|j«S)r©rns r,rzContourSet.<lambda>$s
 $§.¡.Ó"2€r.có|jS)rfr“s r,rzContourSet.<lambda>%s  t×'<Ñ'<€r.cóH|j€'|jj|_|jSt|jtj
«s@t
|jd«r*|jj|j«|_|jS)z9Return the `.Transform` instance used by this ContourSet.Ú_as_mpl_transform)Ú
_transformrrÿr•Ú mtransformsÚ TransformÚhasattrrr“s r,zContourSet.get_transform'srà ?‰?Ð "Ÿi™i×1ˆDŒOðÐô˜TŸ_™_¬k×.CÑ.CÔ˜$Ÿ/™/Ð+>Ô"Ÿo™o×Ç Á ÓJˆDŒOØÐr.cóD|jj«}d|d<|S)_contour_generator)Ú__dict__Úcopy)rnÚstates r,Ú __getstate__zContourSet.__getstate__0s&Ø
×$ˆð'+ˆÐˆ r.r&cóg}g}|jr%|j«\}}t|j«}t |«D}|j t
jddd|j«||j|t|j«z¬««|||«} |||«}
|dk(r'|jdvr|j d|d| d«Œ¢||dz
k(r'|jd vr|j d|d
|
d«ŒÑ|j d| d |d|
d«Œí||fSt|j«D]u\}} |j tgg|j«||j«||j!«|¬ ««|j d|d
|| «d«Œw||fS)a
Return a list of artists and labels suitable for passing through
to `~.Axes.legend` which represent this ContourSet.
The labels have the form "0 < x <= 1" stating the data ranges which
the artists represent.
Parameters
----------
variable_name : str
The string used inside the inequality used on the labels.
str_format : function: float -> str
Function used to format the numbers in the labels.
Returns
-------
artists : list[`.Artist`]
A list of the artists.
labels : list[str]
A list of the labels.
r-r€)rZÚhatchrrPú$z \leq zs$rSz > z < )Ú linewidthr[z = )r<rvrOrrNrRÚmpatchesÚ RectangleÚ
get_facecolorr?r×rQrLr Ú
get_edgecolorÚget_linewidthsÚget_linestyles) rnÚ
variable_nameÚ
str_formatÚartistsrjr‰Ún_levelsrµrLrMrs r,Úlegend_elementszContourSet.legend_elements8ð,ˆØˆà ;‹;Ø:‰NˆF˜4Ÿ;™;Ó'ˆ˜X“ò
PØœxטA˜qØ"×2°3ÑŸ,™, s¬S°·±Ó->Ñ'>Ñ ôñ
# 6¨#¡;Ó/Ù" 6¨#¡;Ó/ؘ!§ ¡ ¨Ñ >Ø—MM Q } o°V¸E¸7À"Ð"EÕ˜H q™LÒ(¨T¯[©[¸OÑ-KØ—MM Q } o°S¸¸¸rÐ"BÕ—MM Q u g¨S°°¸vÀeÀWÈAÐ"NÕ
Pð0˜ˆÐô¯ © Ó
K
œvؘØ×.¨sÑ"×3°CÑ"×3°CÑ ôð 
  = ±ZÀÓ5FÐ4GÀqÐ
Kð˜ˆÐr.c óŽ|d|_|d}t|«dkDr|dnd}tj|j«|_tj
|j«|_||Dcgc]}dgt|«zŒ}}|jr/t|«t|j«dz
k7r7td«t|«t|j«k7r td«t|«t|«k7r td«|Dcgc] }|D]}|ŒŒ
}}}tj|d¬«} | j d¬«|_
| jd¬«|_ t||«D
cgc]&\}}
tjtt||
«ŽŒ(c}
}|_|Scc}wcc}}wcc}
}w) z
Process *args* and *kwargs*; override in derived classes.
Must set self.levels, self.zmin and self.zmax, and update Axes limits.
rr€r;Nz-must be one less number of segments as levelsz)must be same number of segments as levelsz(allkinds has different length to allsegsrv)rLrOrZrTÚzmaxrQÚzminr<rSrzr{rr
rr€r) rnr„ÚallsegsÚallkindsÚsegsÚsegr°Ú flatseglistròÚkindss r,rgzContourSet._process_argsns™ð ˜1Œ Øq‘'ˆÜ! $›i¨!šm4˜’7°ˆÜ—F‘F˜4Ÿ;™;Ó'ˆŒ Ü—FF˜4Ÿ;™;Ó'ˆŒ à Ð Ø7>Ö?¨t˜˜¤ T£Ó?ˆHÐ ;Š;Ü7|œs 4§;¡;Ó/°!Ñ ð"*ó7|œs 4§;¡;Ó Ð!LÓ ˆx‹=œC ›LÒ Ð %,×9˜S°SÒ’qÐ9 Ñ  °!Ô4ˆØ—ZZ Q'ˆŒ
Ø—ZZ Q'ˆŒ
ô+.¨g°xÓ*@÷BÙ&˜4 ô×.´´D¸$ÀÓ0FÒBˆŒ ðˆ
ùò;@ùó :ùóBsÁ3F6ÄF;Æ+Gc
óÖ|j |jS|j}ttjd««}|j
r$t
|jg|j«¢­Žnt
|j|j«}|Dcgc]D\}}t|«r2ttj|«tj|««n|ŒFc}}Scc}}w)z$Compute ``paths`` using C extension.)rr;)
rr
rZÚemptyr<r€Úcreate_filled_contourrvÚcreate_contourrLrO)rnÚcgÚ
empty_pathÚvertices_and_codesÚvsr(s r,rtz-ContourSet._make_paths_from_contour_generatoršà ;‰;Ð —; Ø
×
$ˆÜœ"Ÿ(™( +ˆ
ð{Š{ô
× I¨4×+FÑ+FÓ+HÓ ×! 4§;¡;Ó  ð
ôADÀBÄ”R—^‘^ ¯©¸Ó);Ô<ÈZÑ 2ùó2sÂA C%cóâ|jdd}|j|dk(r<|j«}|jrd|jz|d<n
|dxxdzcc<|jdd}||fS)zB
Return ``(lowers, uppers)`` for filled contours.
NrArg®Gáz®ï?r€)Ú_levelsr²rc)rnr‰s r,rvz!ContourSet._get_lowers_and_uppers§spð˜c˜rÐØ 9‰9˜˜q™ Ò —[‘[“]ˆFØ}Š}Ø  4§9¡9Ñ,q’ àq“ ˜Q‘“ ؘa˜bÐØ˜ÐÐr.có2t|d«s|j«|jj|j«|j |j «|j«tj|j«t|j ««}t|j|j|«D]A\}}}|j|«|j!|j"j%|««ŒCt&|Q«y)NrP)rsr@Úautoscale_NonerLÚ set_arrayrPÚupdate_scalarmappablerZÚ broadcast_torrOrrmrÚ set_alphaÚ set_colorrYrr$rU)rnÚalphasr\Úcvr÷r%s €r,rUzContourSet.changed¶ø€Üt˜YÔ × Ñ Ô
‰ × Ñ  §¡Ô t—| × §¡Ó!1´3°t·|±|Ó3DÓEˆÜ # D§O¡O°T×5FÑ5FÈÓ Oò ˆE2 O‰O˜ O‰O˜D×.×6°rÓ  Õr.cóÊ|j€E|jrtj«|_ntj|dzd¬«|_|jj |j |j«} |jjr|S tj||j k«d}t|«r|dnd}tj||jkD«d}t|«r|ddzn
t|«}|jdvr|dz
}|jdvr|dz}||z
dkr
dt|«}}|||S#t$rYŒÅwxYw)a,
Select contour levels to span the data.
The target number of levels, *N*, is used only when the
scale is not log and default locator is used.
We need two more levels for filled contours than for
line contours, because for the latter we need to specify
the lower and upper boundary of each range. For example,
a single contour boundary, say at z = 0, requires only
one contour line, but two filled regions, and therefore
three levels to provide boundaries for both regions.
r€)Ú min_n_ticksrrArPrSé)rGrcrDrbÚ MaxNLocatorÚ tick_valuesr²Ú
_symmetricÚAttributeErrorrZrOr×)rnr>rrÚunderrêÚoverrës r,Ú_autolevzContourSet._autolevÆs;ð <‰<Ð Ø}Š}Ü%×2 ä1°!°a±%ÀQÔG àl‰l×& t§y¡y°$·)±)Ó<ˆð Ø|‰|×
ð 
˜3 §¡™?Ó+¨AÑܘeœ*ˆU2ŠY¨!ˆÜz‰z˜# § ¡ ™/Ó*¨1ÑÜ œIˆT!‰WqŠ[¬3¨s«8ˆØ ;‰;˜/Ñ !‰GˆBØ ;‰;˜ !‰Gˆ
‰7QŠ;Øœ˜C›ˆBà2bˆzÐøô!ò Ù ð úsÂEÅ E"Å!E"cóX|j€:|r|d}n>tj|t«r|jrgd¢}ndg}nd}n |j}t |t «r|j|«|_n)tj|tj«|_|jr#t|j«dkr td«t|j«dkDrAtjtj|j««d kr td
«yy) zH
Determine the contour levels and store in self.levels.
Nr)rçà?r€r×ér;z*Filled contours require at least 2 levels.r€gz!Contour levels must be increasing)rLrZÚ
issubdtypeÚboolr<r•rÚasarrayÚfloat64rOrSrQ)rnÚz_dtypeÚ
levels_args r,Ú_process_contour_level_argsz&ContourSet._process_contour_level_argsñð ;‰;Ð ÙØ! !™W‘
ܘw¬Ô—;’;Ú!+Jà"$ 
àŸˆJÜ j¤(Ô Ÿ-™-¨
Ó3ˆDŸ*™* Z´·±Ó<ˆDŒKØ ;Š;œ3˜tŸ{™{Ó+¨aÒÐ ˆt{‰{Ó ˜aÒ ¤B§F¡F¬2¯7©7°4·;±;Ó+?Ó$@ÀCÒ$GÜÐ %HÐ r.cóŒt|j«|_|jrd\}}nd\}}|jdvr|jj d|«|jdvr|jj
|«tj|j«|_|js|j|_
y|jrKtj|jdd«tj|jdd«z|_
yd |jdd|jddzz|_
y)
a&
Assign values to :attr:`layers` based on :attr:`levels`,
adding extended layers as needed if contours are filled.
For line contours, layers simply coincide with levels;
a line is a thin layer. No extended levels are needed
with line contours.
)gL‚¢]?é çRy«ãXÖs)gRy«ãXÖórá©rRrQr©rRrTNrAr€r×) rMrLrcr×rRrZr<ÚlayersÚsqrt)rnrLrMs r,rhzContourSet._process_levels
ô˜DŸK™KÓŒ à =Š=Ø(‰LˆE‘5à(‰LˆE ;‰;˜/Ñ L‰L× Ñ   5Ô ;‰;˜/Ñ L‰L× Ñ  Ô —z‘z $§,¡,Ó/ˆŒ à{Š{ØŸ+™+ˆDŒKØ ð =Š=äŸ7™7 4§<¡<°°Ð#4ÓŸW™W T§\¡\°!°"Ð%5Ó7ˆD §¡¨c¨rÐ!2°T·\±\À!À"Ð5EÑ!EÑFˆDKr.cól|jj|_|jŒdt|j«}}|j
r+|dz}|j dvr|dz}|j dvr|dz
}tt||««|_ |jtj««n|j|_ |jj|j«|j!|j«|j#«|j dvrd|j_yy)a
Color argument processing for contouring.
Note that we base the colormapping on the contour levels
and layers, not on the actual range of the Z values. This
means we don't have to worry about bad values in Z, and we
always have the full dynamic range available for the selected
levels.
The color is based on the midpoint of the layer, except for
extended end layers. By default, the norm vmin and vmax
are the extreme values of the non-extended levels. Hence,
the layer color extremes are not the extreme values of
the colormap itself, but approach those values as the number
of levels increases. An advantage of this scheme is that
line contours, when added to filled contours, take on
colors that are consistent with those of the filled regions;
for example, a contour line on the boundary between two
regions will have a color intermediate between those
of the regions.
Nrr€)rRrTrQF)r?Ú
monochromer4rOrLr<r×rMrNrPror]rar@r.)rns r,rszContourSet._process_colors/ð.Ÿ)™)×ŒØ ;‰;Ð œ˜DŸK™KÓ(ˆBØ{Š{Øa‘à—;‘; /ј!‘G—;‘; /ј!G¤ b¨"£
Ó.ˆDŒLØ M‰Mœ'Ÿ.™.Ó Ÿ;™;ˆDŒLØ ‰ × Ñ  §¡Ô t—| × ;‰;Ð "ˆDI‰I 1r.có&t|j«}|€.tjd}|tjd}|g|zSt j
|«s|g|zSt
|«}|tj|t|«z «zd|S)Nzcontour.linewidthzlines.linewidth) rOrLrererZrcrMr )rnr=ÚNlevÚdefault_linewidths r,rwzContourSet._process_linewidths[sÜ4—;‘;ÓˆØ Ð Ü #§ ¡ Ð-@Ñ AÐ Ø Ð(Ü$'§L¡LÐ1BÑ$CÐÑ ˜<  ˜)ˆ¤§¡¨4´#°j³/Ñ+AÓ!BÑBÀEÀTÐ Jr.có t|j«}|€cdg|z}|jrO|j|jz
dz}t |j«D]\}}||ksŒ |j ||<Œ|St|t«r|g|z}|Stj|«r]t|«}t|«|kr/ttj|t|«z ««}||z}t|«|kDr|d|}|Std«)solidgV瞯Ò<z&Unrecognized type for linestyles kwarg)rOrLrQrHr•rrZrcrMr rS)rnr>Ú tlinestylesÚepsrqrrÚnrepss r,rxzContourSet._process_linestyleshsÜ4—;ˆØ Ð Ø"˜) dÑ*ˆK؊؟ T§Y¡YÑ/°%Ñ7ܯ © ÓBFA˜S“yØ)-×)AÑ)A˜  AšðBðÐô˜*¤cÔ)˜l¨TÑ1 ðÐô˜ZÔ" . Ü# ¤§¡¨¬s°:«Ñ(>Ó ?Ó@EØ"-°Ñ"5# *Ø"-¨e¨tÐ"4Ðô!Ð!IÓJr.cóà|jr td«|tt|j««}t
j }dx}x}}|D]˜}|j|}d} |j«D]r}
t|
j«sŒ|j«j|
j«} t| |«\} }
}| |kr| }|}|d| z}|
}| t|
«z
} ŒtŒš|||fS)
Find the point in the unfilled contour plot that is closest (in screen
space) to point *xy*.
Parameters
----------
xy : tuple[float, float]
The reference point (in screen space).
indices : list of int or None, default: None
Indices of contour levels to consider. If None (the default), all levels
are considered.
Returns
-------
idx_level_min : int
The index of the contour level closest to *xy*.
idx_vtx_min : int
The index of the `.Path` segment closest to *xy* (at that level).
proj : (float, float)
The point in the contour plot closest to *xy*.
z'Method does not support filled contoursNrr€) r<rSrNrOrrZÚinfrrr7)rnÚxyroÚd2minrrÚproj_minÚ idx_levelrØÚ
idx_vtx_startr"ÚlcÚd2rÚlegs r,rz ContourSet._find_nearest_contoursð6 ;Š;ÜÐ ˆ?ÜœC § ¡ Ó-ˆGäˆØ15Ð
Ð5˜   ò
.ˆIØ—;‘;˜yÑ)ˆD؈×
.ܘ7ר×)×3°G×4DÑ4DÓEÜ ;¸Ó C
D˜#ؘEØ$-MØ"% a¡&¨=Ñ"8#¤ Ñ-
ñ

˜k¨8Ð3r.cóêdx}x}}t«5}|s3|j|jtj«¬««|j ||f|«\} }
\} } ddd« ut
jgtt|j| j««¢«}
|
j
d«}|dk(r|
n
|
|
|dz
z
} |z
dz |z
dzz}| ||  |fS#1swYŒˆxYw)
Find the point in the contour plot that is closest to ``(x, y)``.
This method does not support filled contours.
Parameters
----------
x, y : float
The reference point.
indices : list of int or None, default: None
Indices of contour levels to consider. If None (the default), all
levels are considered.
pixel : bool, default: True
If *True*, measure distance in pixel (screen) space, which is
useful for manual contour labeling; else, measure distance in axes
space.
Returns
-------
path : int
The index of the path that is closest to ``(x, y)``. Each path corresponds
to one contour level.
subpath : int
The index within that closest path of the subpath that is closest to
``(x, y)``. Each subpath corresponds to one unbroken contour line.
index : int
The index of the vertices within that subpath that are closest to
``(x, y)``.
xmin, ymin : float
The point in the contour plot that is closest to ``(x, y)``.
d2 : float
The squared distance from ``(xmin, ymin)`` to ``(x, y)``.
N)rrr€r;)
rÚ
enter_contextÚ_cm_setr˜ÚIdentityTransformrrZr€rOrrÚ searchsorted)rnr&r'roÚpixelÚsegmentrÚstackÚi_levelÚi_vtxÚxminÚyminÚ
cc_cumlenss r,Úfind_nearest_contourzContourSet.find_nearest_contour´sðD#ˆÐ#%˜
‹[ð W˜EÙð×# D§L¡LÜ)×%1ó%?ô@ð,0×+EÑ+EÀqÈ!ÀfÈgÓ+VÑ (ˆGU™L˜T 4÷ Wð Ð ÜŸØN”#”c˜4Ÿ;™; wÑPˆJà ×-¨e°WÓ=ˆš\E¨u°zÀ'ÈAÁ+Ñ7NÑ/Nˆq&˜1  ¨™{Ñ*ˆBà˜ %¨¨t°RÐ8÷! Wð Wús AC)Ã)C2c
ó|j}t|«}|jrtd|jD««rt
||«y|j«}|jdk(rd}t|«D}tj|||g¬«5|j|j|t|j«z|j«|g|j«|t|j««zg|j«|t|j««zg||t|«z¬«5t
||«ddd«ddd«Œòy#1swYŒxYw#1swYŒ
xYw)Nc3ó$K|]}|duŒ
y­wr)rs r,r…z"ContourSet.draw.<locals>.<genexpr>ísèø€Ò!J°E %¨4¤-Ñ!Jùsr)rW)r)r=r>Ú
edgecolors)rrOr<Úallr?r$r"Úget_edgecolorsr<rNrkÚ _setattr_cmrüÚ get_arrayr©)rnrÚpathsÚn_pathsr
r%s €r,r"zContourSet.drawês_ø€Ø ˆÜe“*ˆØ{Š{œcÑ!J¸T¿\¹\Ô!JÔ ‰G‰L˜Ô à×*ˆ
Ø ?‰?˜aÒ Ø"ˆ˜“>ò 'ˆ×" °s±° Ô
'¸t¿|¹|Ø—ll ¨T¯\©\Ó):Ñ#:Ñ—~Ñ ×1°#¼¸D×<OÑ<OÓ<QÓ8RÑ2RÑ ×1°#¼¸D×<OÑ<OÓ<QÓ8RÑ2RÑ% c¬C°
«OÑ&;Ñ @Ló@ñ
 ˜




'ú÷

'ús%ÂB3E=ÅE1ÅE=Å1E: Å6E=Å=F )NT)r&r'r(r)r_Úpropertyr³r´r>r rrgrtrvrUrhrsrwrxrrr"r*r+s@r,r:r:)ø„ñ(ðV U°tÈØ ¨°TÀ$Ø 4¨d¸ÀDب ¸tÈAبÀ4ÐSWö GñRñ$€Gññ$€Hñ
Ñ 3€EÙÑ=€Jòòð-0¸Có4òl*òX 
 ôò )òVBò2#GòJ*#òX Kòó.34ój49÷l'r.r:có0eZdZdZdddœdZdZdZdZy)ÚQuadContourSetzÚ
Create and store a set of contour lines or filled regions.
This class is typically not instantiated directly by the user but by
`~.Axes.contour` and `~.Axes.contourf`.
%(contour_set_attributes)s
N)Ú corner_maskÚ algorithmc
ó–|r¼t|dt«r©|j|dj|_|dj|_|dj|_|dj
|_|dj }|dj|_|dj|_|dj|_ nddl
}|tjd}tjjd|«||_ |€%|jdk(rd}ntjd}||_|j||«\}}} |j||| |j|j
|j j"|j$j&|j(¬«}|j+«}
|
|j,j.k7r—t1|
j3|j,j.««ri|
|j,j.z
} t5j6|j8|j8g«j:} | j=| «}
|
d}|
d }t?j@|«t?j@|«g|_t?jB|«t?jB|«g|_||_|S)
z*
Process args and kwargs.
rNzcontour.algorithmÚmpl2005Fzcontour.corner_mask)rrÚ line_typeÚ fill_typeÚ
chunk_size).r).r€)"r•rrLÚ _corner_maskrœrzr{Ú
_algorithmÚ contourpyrereÚvalidateÚ
_contour_argsÚcontour_generatorÚLineTypeÚ SeparateCodeÚFillTypeÚ OuterCoderFrrÿrzÚcontains_branch_seperatelyrZÚvstackÚflatrºrrrQrT)rnrrr„r rr&r'Úzr
Ú
trans_to_dataÚptsÚtransformed_ptss r,rgzQuadContourSet._process_args
sJñ ”J˜t A™w¬Ô{‰{Ð" 1™gŸn™n ؘQ™Ÿ ˆDŒIؘQ™Ÿ ˆDŒIØ $ Q¡× 4Ñ 4ˆDÔ Ø $ Q¡× :Ñ :Рؘa™ŸˆDŒJؘa™ŸˆDŒJØ" 1™g×0ˆDŽOã àÐ ÜŸL™LÐ)<Ñ= Ü L‰L× !Ð"5Ñ 6°yÔ 'ˆDŒOàЗ?? #(Kä"%§,¡,Ð/DÑ"EKØ +ˆ àרvÓ6‰GˆAˆq!à )× ;Ñ ;Ø1a˜dŸo™o¸4×;LÑ;LØ#×,×,ן;™;ð !<ó!(Ð ð ×$ˆT—YYט×4°T·Y±Y×5HÑ5HÓJØ ! D§I¡I×$7Ñ$7Ñ 7
Ü—i‘i §¡¨¯©Ð 0Ó1×3Ø"/×"9Ñ"9¸#Ó">Ø# +Ø# +äŸ&™& )¤R§V¡V¨A£YÐ/ˆDŒJÜŸ&™& )¤R§V¡V¨A£YÐ/ˆDŒJà"3ˆÔàˆ
r.có.|jrd}nd}t|«}d|cxkrdkr1nn.|^}}tj|«}|j |«\}}nEd|cxkrdkr"nn|^}}}}|j ||||«\}}}nt
j|d|¬«tj|d¬ «}|j«jt«|_ |j«jt«|_|jre|jdkrVtj |dk|«}t
j"d
«|j«jt«|_|j%||j&«|||fS) contourfÚcontourrr;rOz from 1 to 4)ÚtakesÚgivenF)z,Log scale: values of z <= 0 have been masked)r<rOrÚ_initialize_x_yÚ
_check_xyzrÚ nargs_errorÚmasked_invalidrTÚastypeÚfloatr±rQrcÚ masked_whereruÚdtype) rnr„ÚfnÚnargsr(r&r'Úz_origs r,rzQuadContourSet._contour_argsDsCØ ;Š;؉BàˆBÜD“ ˆà ˆuŒ>˜ˆHˆAÜ
˜1“
ˆ×Ó*‰DˆA‰qØ
Œ^˜!^Ø"&Ð ˆAˆq&˜—oo ¨F°FÓ;‰GˆAˆq×" 2¨]À%Ô × Ñ ˜a eÔ Ø—E‘E“G—N‘N¤5ÓŒ Ø—E‘E“G—N‘N¤5ÓŒ Ø =Š=˜TŸY™Y¨!š^Ü  Q¡¨Ó*ˆAÜ × Ñ Ð ŸŸ¤uÓ-ˆDŒIØ ×¨q¯w©wÔ1aˆr.cóª|jjd|fd|fg|«\}}tj|tj¬«}tj|tj¬«}t j|«}|j dk7rtd|j d«|jddks|jddkrtd |j«|j\}}|j |j k7r&td
|j d |j d «|j dk(rd|j\}|j\}||k7rtd
|d|d«||k7rtd|d|d«tj||«\}}n¦|j dk(r~|j|jk7r&td|jd|jd«|j|jk7r?td|jd|jd«td|j d«|||fS)z€
Check that the shapes of the input arrays match; if x and y are 1D,
convert them to 2D using meshgrid.
r&r')r8r;úInput z must be 2D, not ÚDrr€ú>Input z must be at least a (2, 2) shaped array, but has shape zNumber of dimensions of x (z ) and y (z) do not matchz
Length of x (z%) must match number of columns in z (ú)z
Length of y (z") must match number of rows in z (z Shapes of x z and z z
do not matchz Shapes of y z%Inputs x and y must be 1D or 2D, not )
rÚ_process_unit_inforZrÚndimÚ TypeErrorÚshapeÚmeshgrid) rnr&r'r(r„ÚNyÚNxÚnxÚnys r,r2zQuadContourSet._check_xyz_s:ð
y‰y×+¨c°1¨X¸¸Q°xÐ,@À&ÓI‰ˆˆ J‰J§
¡
Ô +ˆÜ J‰J§
¡
Ô Ü J‰Jq‹Mˆà 6‰6QŠ;ÜÐ6°q·v±v°h¸ 7‰71‰:˜Š>˜QŸW™W Q™Z¨!š^Üð-Ø-.¯W©W¨Ið
ˆˆBà 6‰6Q—V‘VÒ ÜÐ9¸!¿&¹&¸ðB Ø !§¡˜x 
6‰6QŠ;Ø—''‰Cˆ—''‰CˆRŠxÜ ¨tð41Ø13°°Að!7óRŠxÜ -°¨tð4.Ø.0¨T°ð!4ó—;;˜q $‰DˆA‰qØ
V‰VqŠ[Øw‰w˜!Ÿ'™'ÒØ" 1§7¡7 )¨7°1·7±7°)¸KðKàw‰w˜!Ÿ'™'ÒØ" 1§7¡7 )¨7°1·7±7°)¸KðKôÐCÀAÇFÁFÀ8È1Ð !Qˆwˆr.có~|jdk7rtd|jd«|jddks|jddkrtd|j«|j\}}|j|j€<t j t j|«t j|««S|j\}}}}t j|||«}t j|||«} t j || «S|j d|d|f\}}}}n|j\}}}}||z
|z }
||z
|z } |t j|«dz|
zz}|t j|«dz| zz} |jd k(r| ddd
} t j || «S) a
Return X, Y arrays such that contour(Z) will match imshow(Z)
if origin is not None.
The center of pixel Z[i, j] depends on origin:
if origin is None, x = j, y = i;
if origin is 'lower', x = j + 0.5, y = i + 0.5;
if origin is 'upper', x = j + 0.5, y = Nrows - i - 0.5
If extent is not None, x and y will be scaled to match,
as in imshow.
If origin is None and extent is not None, then extent
will give the minimum and maximum values of x and y.
r;r=r>rr€r?Nr×rMrA) rBrCrDr@rArZrEÚarangeÚlinspace) rnr(rFrGr&r'ÚdxÚdys r,r1zQuadContourSet._initialize_x_yŠsð
6‰6QŠ;ÜÐ6°q·v±v°h¸aÐ
W‰WQ‰Z˜!Š^˜qŸw™w q™z¨Aš~Üð-Ø-.¯W©W¨Ið
—W‘W‰FˆBØ ;‰;Ð Ø{‰{З{{¤2§9¡9¨R£=´"·)±)¸B³-Ó@à!%§¡˜BÜ—K‘K  B¨Ó+Ü—K‘K  B¨Ó+Ü—{‘{ 1 aÓ ;‰;Ð Ø  Q¨˜^‰NˆBB™à!Ÿ[™[‰NˆBØ2‰g˜‰^ˆØ2‰g˜‰^ˆØ ”"—))˜B“- Ñ +ˆØ ”"—))˜B“- Ñ +ˆØ ;‰;˜ $B$ˆ{‰{˜1˜ Ð r.)r&r'r(r)rgrr2r1rr.r,rrÿs$ñð04¸8òtò6)óV'!r.ra$
`.contour` and `.contourf` draw contour lines and filled contours,
respectively. Except as noted, function signatures and return values
are the same for both versions.
Parameters
----------
X, Y : array-like, optional
The coordinates of the values in *Z*.
*X* and *Y* must both be 2D with the same shape as *Z* (e.g.
created via `numpy.meshgrid`), or they must both be 1-D such
that ``len(X) == N`` is the number of columns in *Z* and
``len(Y) == M`` is the number of rows in *Z*.
*X* and *Y* must both be ordered monotonically.
If not given, they are assumed to be integer indices, i.e.
``X = range(N)``, ``Y = range(M)``.
Z : (M, N) array-like
The height values over which the contour is drawn. Color-mapping is
controlled by *cmap*, *norm*, *vmin*, and *vmax*.
levels : int or array-like, optional
Determines the number and positions of the contour lines / regions.
If an int *n*, use `~matplotlib.ticker.MaxNLocator`, which tries
to automatically choose no more than *n+1* "nice" contour levels
between minimum and maximum numeric values of *Z*.
If array-like, draw contour lines at the specified levels.
The values must be in increasing order.
Returns