rL itdZddlZddlZddlmZddlmZmZm Z m Z m Z m ZmZddlmZmZmZmZmZddlmZddlmZdd lmZd Zd Zd Zd Z GddejBZ"d3dZ#Gdde jHZ%d3dZ&d4dZ'd4dZ(d4dZ)d4dZ*GddeZ+d3dZ,GddeZ-d3dZ.GddeZ/Gd d!e/Z0d"Z1d3d#Z2d4d$Z3Gd%d&eZ4Gd'd(eZ5d5d)Z6Gd*d+eZ7d3d,Z8d-Z9d.Z:d/Z;d6d0Zy)8zx Module containing 3D artist code and functions to convert 2D artists into 3D versions which can be added to an Axes3D. N)contextmanager)_apiartistcbookcolorslinestextpath) CollectionLineCollectionPolyCollectionPatchCollectionPathCollection) Normalize)Patch)proj3dc*|dzdz}|dkDr|dz }|S)z?Return the given angle normalized to -180 < *a* <= 180 degrees.ihas `/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/mpl_toolkits/mplot3d/art3d.py _norm_anglers$ SCA3w G Hc*|dzdz}|dkDr|dz }|S)z=Return the given angle normalized to -90 < *a* <= 90 degrees.rZrrs r_norm_text_angler"s$ SCA2v G HrcR|dk(rtjdS|dk(rtjdS|dk(rtjdS|tjdStj|r#t|dk(rtj|St d ) a Return a direction vector. Parameters ---------- zdir : {'x', 'y', 'z', None, 3-tuple} The direction. Possible values are: - 'x': equivalent to (1, 0, 0) - 'y': equivalent to (0, 1, 0) - 'z': equivalent to (0, 0, 1) - *None*: equivalent to (0, 0, 0) - an iterable (x, y, z) is converted to an array Returns ------- x, y, z : array The direction vector. x)rrry)rrrz)rrr)rrrz2'x', 'y', 'z', None or vector of length 3 expected)nparrayiterablelen ValueError)zdirs rget_dir_vectorr**s( s{xx "" xx "" xx "" xx "" T s4yA~xx~MNNrc 0tjj||jjk||jj kD||jj k||jjkD||jjk||jj kDf}tjj||}tjj||}tjj||}|||fS)aM Return original points with points outside the axes view limits masked. Parameters ---------- xs, ys, zs : array-like The points to mask. axes : Axes3D The axes to use for the view limits. Returns ------- xs_masked, ys_masked, zs_masked : np.ma.array The masked points. )mask) r$ logical_orreduce xy_viewLimxminxmaxyminymax zz_viewLimmar%)xsyszsaxesr, xs_masked ys_masked zs_maskeds r _viewlim_maskr=Ls ==  doo&:&:!:!#doo&:&:!:!#doo&:&:!:!#doo&:&:!:!#doo&:&:!:!#doo&:&:!: !< =D  BT *I BT *I BT *I i **rcleZdZdZd dZdZd fd ZdZd dZe jdZ d dZ xZ S) Text3Da* Text object with 3D position and direction. Parameters ---------- x, y, z : float The position of the text. text : str The text string to display. zdir : {'x', 'y', 'z', None, 3-tuple} The direction of the text. See `.get_dir_vector` for a description of the values. axlim_clip : bool, default: False Whether to hide text outside the axes view limits. Other Parameters ---------------- **kwargs All other parameters are passed on to `~matplotlib.text.Text`. c ptjj||||fi||j|||yN)mtextText__init__set_3d_properties)selfr r!r"r r) axlim_clipkwargss rrDzText3D.__init__~s1 D!Q77 q$ 3rcH|j|j|jfS)z*Return the (x, y, z) position of the text.)_x_y_zrFs rget_position_3dzText3D.get_position_3dsww((rcxt||dd|j|d|t||_yy)ax Set the (*x*, *y*, *z*) position of the text. Parameters ---------- xyz : (float, float, float) The position in 3D space. zdir : {'x', 'y', 'z', None, 3-tuple} The direction of the text. If unspecified, the *zdir* will not be changed. See `.get_dir_vector` for a description of the values. N)super set_positionset_zr*_dir_vec)rFxyzr) __class__s rset_position_3dzText3D.set_position_3ds? S!W% 3q6  *40DM rc ||_d|_y)zl Set the *z* position of the text. Parameters ---------- z : float TN)rLstale)rFr"s rrSz Text3D.set_zs rcN||_t||_||_d|_y)a Set the *z* position and direction of the text. Parameters ---------- z : float The z-position in 3D space. zdir : {'x', 'y', 'z', 3-tuple} The direction of the text. Default: 'z'. See `.get_dir_vector` for a description of the values. axlim_clip : bool, default: False Whether to hide text outside the axes view limits. TN)rLr*rT _axlim_cliprY)rFr"r)rGs rrEzText3D.set_3d_propertiess&&t, % rc|jrt|j|j|j|j \}}}t jj|||fjjt j}n<|j|j|j}}}t j|||g}tj|||jzg|j j }|dd|ddz }|dd|ddz }t#j$t#j&||} t)j*||dd|ddt-| 5t.j0j3||dddd|_y#1swYd|_yxYw)Nrr)rJrK _rotationF)r[r=rJrKrLr9r$r5 row_stackravelfillednan asanyarrayr_proj_trans_pointsrTMmathdegreesatan2r _setattr_cmrrBrCdrawrY) rFrendererr6r7r8 position3dprojdxdyangles rriz Text3D.drawsh   &tww$))LJBB"b"6<<>EEbffMJ$''477BBB|4J(( dmm3 4diikkC !WQZ$q'!* $ !WQZ$q'!* $ TZZB/0   tQ tAwqz)9%)@B , JJOOD( + ,  , s !F44GcyrAr)rFrjs r get_tightbboxzText3D.get_tightbboxsr)rrrr"FrArr"F)__name__ __module__ __qualname____doc__rDrNrWrSrErallow_rasterizationrirq __classcell__rVs@rr?r?hs@*4 )1" &  $rr?c@t|_|j|||y)ax Convert a `.Text` to a `.Text3D` object. Parameters ---------- z : float The z-position in 3D space. zdir : {'x', 'y', 'z', 3-tuple} The direction of the text. Default: 'z'. See `.get_dir_vector` for a description of the values. axlim_clip : bool, default: False Whether to hide text outside the axes view limits. N)r?rVrE)objr"r)rGs r text_2d_to_3dr}sCM!T:.rcdeZdZdZddfd Zd dZdZdZejfdZ xZ S) Line3Da 3D line object. .. note:: Use `get_data_3d` to obtain the data associated with the line. `~.Line2D.get_data`, `~.Line2D.get_xdata`, and `~.Line2D.get_ydata` return the x- and y-coordinates of the projected 2D-line, not the x- and y-data of the 3D-line. Similarly, use `set_data_3d` to set the data, not `~.Line2D.set_data`, `~.Line2D.set_xdata`, and `~.Line2D.set_ydata`. F)rGcbt|ggg|i||j|||||_y)aM Parameters ---------- xs : array-like The x-data to be plotted. ys : array-like The y-data to be plotted. zs : array-like The z-data to be plotted. *args, **kwargs Additional arguments are passed to `~matplotlib.lines.Line2D`. N)rQrD set_data_3dr[)rFr6r7r8rGargsrHrVs rrDzLine3D.__init__s8 R1$1&1 R$%rc |j}|j}tj|j }t j |t|}t|||||_ ||_ d|_ y)a Set the *z* position and direction of the line. Parameters ---------- zs : float or array of floats The location along the *zdir* axis in 3D space to position the line. zdir : {'x', 'y', 'z'} Plane to plot line orthogonal to. Default: 'z'. See `.get_dir_vector` for a description of the values. axlim_clip : bool, default: False Whether to hide lines with an endpoint outside the axes view limits. TN) get_xdata get_ydatar_to_unmasked_float_arrayr_r$ broadcast_tor' juggle_axes_verts3dr[rY)rFr8r)rGr6r7s rrEzLine3D.set_3d_propertiessj^^  ^^   + +B / 5 5 7 __RR )#BB5 % rct|dk(r|d}td|D](\}}tj|rt |d||_d|_y)ag Set the x, y and z data Parameters ---------- x : array-like The x-data to be plotted. y : array-like The y-data to be plotted. z : array-like The z-data to be plotted. Notes ----- Accepts x, y, z arguments or a single array-like (x, y, z) rrrUz must be a sequenceTN)r'zipr$r& RuntimeErrorrrY)rFrnamerUs rrzLine3D.set_data_3dsc" t9>7DUD) AID#;;s#"dV+>#?@@ A  rc|jS)z Get the current data Returns ------- verts3d : length-3 tuple or array-like The current data as a tuple or array-like. )rrMs r get_data_3dzLine3D.get_data_3d.s}}rcf|jr&tg|j|j\}}}n|j\}}}t j ||||jj |jj\}}}}|j||t |)|d|_ y)NF) r[r=rr9r_proj_transform_cliprd _focal_lengthset_datarQrirY) rFrjxs3dys3dzs3dr6r7r8tisrVs rriz Line3D.draw9s   ,GdmmGTYYG D$#}} D$ 55dD$6:iikk6:ii6M6MOBC b"  X rrs) rtrurvrwrDrErrrrxriryrzs@rrrs;6;&$.2     rrc@t|_|j|||y)a Convert a `.Line2D` to a `.Line3D` object. Parameters ---------- zs : float The location along the *zdir* axis in 3D space to position the line. zdir : {'x', 'y', 'z'} Plane to plot line orthogonal to. Default: 'z'. See `.get_dir_vector` for a description of the values. axlim_clip : bool, default: False Whether to hide lines with an endpoint outside the axes view limits. N)rrVrE)liner8r)rGs r line_2d_to_3drGsDN2tZ0rc $tj|t|}|jdd}t ||Dcgc]\\\}}}}|||f}}}}}|Dcgc]\}}}t ||||} }}}| Scc}}}}wcc}}}w)zConvert a path to a 3D segment.Fsimplifycurves)r$rr' iter_segmentsrr) r r8r)pathsegsr r!coder"segseg3ds r_path_to_3d_segmentrZs SY 'B!!5!?H03Hb0A B B,.6Aq4!Aq!9 BC B9< = =IQ1[Aq$ ' =E = L C =s B $B c tj|s tj|t|}n"t|t|k7r t dt ||Dcgc]\}}t |||}}}|Scc}}w)z6Convert paths from a collection object to 3D segments.z-Number of z-coordinates does not match paths.)r$r&rr'r(rr)pathsr8r)r pathzsegss r_paths_to_3d_segmentsrds{ ;;r? __RU , r7c%j LM M #5"~ /e eT 2 /D / K /s'Bc btj|t|}|jdd}t ||Dcgc]\\\}}}}|||f|f}}}}}|r/t |\} } | Dcgc]\}}}t ||||} }}}ng} g} | t | fScc}}}}wcc}}}w)z/Convert a path to a 3D segment with path codes.Fr)r$rr'rrrlist) r r8r)rr r!rr" seg_codesrcodesrs r_path_to_3d_segment_with_codesrrs SY 'B!!5!?H4; && 9sA1ceZdZdZdZy) Collection3DzA collection of 3D paths.c $|jDcgc]\}}| }}}|jrU|Dcgc]J}tjj t g|j |jj L}}|Dcgc]7}tjg|j |jj9}}t||jDcgc]A\\}}}\}}tjtjj||g|Cc}}}}|_tj |Dcgc]\}}}| c}}}t#|r|j%SdScc}}wcc}wcc}wcc}}}}wcc}}w)z0Project the points according to renderer matrix.eA)_3dverts_codesr[r$r5r^r=Tr9rproj_transformrdrmpathPath column_stack_paths concatenater'min) rFvs_vs_list xyzs_listr6r7csr8s rdo_3d_projectionzCollection3D.do_3d_projectionsF#'#6#67%"a277   !(*uu}'Fbdd'FDII'FGII*G*IPQ2V**>BDD>$))++>Q Q36y$BUBU3VXX/;BABzz"%%"4"4b"X">CX ^^ :HAq"R: ;r7rvvx++8*QX:s E4AE:>*A'q!Q5>%>sAct|ds9|jj|j_|j |j S)N_path2d)hasattrr9get_projrdrrrMs rget_pathzPatch3D.get_path s<tY')),,.DIIK  ! ! #||rc|j}|jr"tgt||j\}}}n t|\}}}t j ||||jj|jj\}}}}tjtjj||g|_t|SrA)rr[r=rr9rrrdrrrr$r5rrr rFsr6r7r8vxsvysvzsviss rrzPatch3D.do_3d_projections OO   &;Q;;JBBaJBB#88R9=9=9P9PRS#szz"%%"4"4c3Z"@A 3xrrs) rtrurvrwrDrErrryrzs@rrrs%"$#%5"&* rrc.eZdZdZdddddZd dZdZy ) PathPatch3Dz 3D PathPatch object. rr"Frc Xtj|fi||j||||y)a Parameters ---------- path : zs : float The location along the *zdir* axis in 3D space to position the path patch. zdir : {'x', 'y', 'z', 3-tuple} Plane to plot path patch orthogonal to. Default: 'z'. See `.get_dir_vector` for a description of the values. axlim_clip : bool, default: False Whether to hide path patches with a point outside the axes view limits. N)rrDrE)rFr r8r)rGrHs rrDzPathPatch3D.__init__%s) t&v& tRz:rcntj||j||||j|_y)a Set the *z* position and direction of the path patch. Parameters ---------- path : zs : float The location along the *zdir* axis in 3D space to position the path patch. zdir : {'x', 'y', 'z', 3-tuple} Plane to plot path patch orthogonal to. Default: 'z'. See `.get_dir_vector` for a description of the values. axlim_clip : bool, default: False Whether to hide path patches with a point outside the axes view limits. rN)rrErr_code3d)rFr r8r)rGs rrEzPathPatch3D.set_3d_properties7s1 !!$ "4-7 " 9zz rc|j}|jr"tgt||j\}}}n t|\}}}t j ||||jj|jj\}}}}tjtjj||g|j|_t!|SrA)rr[r=rr9rrrdrrrr$r5rrrrrs rrzPathPatch3D.do_3d_projectionKs OO   &;Q;;JBBaJBB#88R9=9=9P9PRS#szz"%%"4"4c3Z"@$,,O 3xrNrs)rtrurvrwrDrErrrrrr s$&CE;$"( rrc|j}|j}|j|}t|r|dSt j gS)z2Return a list of vertices for the path of a patch.r)get_patch_transformr to_polygonsr'r$r%)patchtransr polygonss r_get_patch_vertsr XsI  % % 'E >> D&Hh-8A;9RXXb\9rcXt|}t|_|j||||y)z*Convert a `.Patch` to a `.Patch3D` object.N)r rrVrE)r r"r)rGrs rpatch_2d_to_3dr`s' U #EEO E1dJ7rc|j}|j}|j|}t|_|j |||y)z2Convert a `.PathPatch` to a `.PathPatch3D` object.N)rrtransform_pathrrVrE) pathpatchr"r)r r rs rpathpatch_2d_to_3drgsH    D  ) ) +E   &E%I q$/rcleZdZdZdddddfd ZdZd Zd Zdd Zfd Z d Z fdZ fdZ xZ S)Patch3DCollectionz% A collection of 3D patches. rr"TFr8r) depthshaderGcX||_t||i||j|||y)a Create a collection of flat 3D patches with its normal vector pointed in *zdir* direction, and located at *zs* on the *zdir* axis. 'zs' can be a scalar or an array-like of the same length as the number of patches in the collection. Constructor arguments are the same as for :class:`~matplotlib.collections.PatchCollection`. In addition, keywords *zs=0* and *zdir='z'* are available. Also, the keyword argument *depthshade* is available to indicate whether to shade the patches in order to give the appearance of depth (default is *True*). This is typically desired in scatter plots. N) _depthshaderQrDrErFr8r)rrGrrHrVs rrDzPatch3DCollection.__init__vs1 & $)&) r44rc|jSrArrMs rget_depthshadez Patch3DCollection.get_depthshaderc ||_d|_yz Set whether depth shading is performed on collection members. Parameters ---------- depthshade : bool Whether to shade the patches in order to give the appearance of depth. TNrrYrFrs rset_depthshadez Patch3DCollection.set_depthshade& rc ||_d|_yrrrs rrzPatch3DCollection.set_sort_zposrrc|j|j}t|dkDr|j\}}ng}g}t ||t j |||_td|_ d|_ ||_ d|_ y)aE Set the *z* positions and direction of the patches. Parameters ---------- zs : float or array of floats The location or locations to place the patches in the collection along the *zdir* axis. zdir : {'x', 'y', 'z'} Plane to plot patches orthogonal to. All patches must have the same direction. See `.get_dir_vector` for a description of the values. axlim_clip : bool, default: False Whether to hide patches with a vertex outside the axes view limits. rrNT) update_scalarmappable get_offsetsr'rrr$ atleast_1d _offsets3dslice_z_markers_idx_vzsr[rYrFr8r)rGoffsetsr6r7s rrEz#Patch3DCollection.set_3d_propertiess~$ ""$""$ w>rc>|jt| SrAr=rQ get_facecolorrFrVs rrAzPatch3DCollection.get_facecolor66uw7L7NOOrctj|jdr|jS|j t |SNfacer _str_equal _edgecolorsrAr=rQ get_edgecolorrBs rrJzPatch3DCollection.get_edgecolorC   D,,f 5%%' '66uw7L7NOOrr)rtrurvrwrDrr#rrErr=rArJryrzs@rrrqsH CDU5(   > ?PPPrrceZdZdZdddddfd ZfdZd Zdd Zdfd Zfd Z d Z dZ dZ e fdZdZfdZfdZxZS)Path3DCollectionz# A collection of 3D paths. rr"TFrct||_d|_t| |i||j |||d|_y)a Create a collection of flat 3D paths with its normal vector pointed in *zdir* direction, and located at *zs* on the *zdir* axis. 'zs' can be a scalar or an array-like of the same length as the number of paths in the collection. Constructor arguments are the same as for :class:`~matplotlib.collections.PathCollection`. In addition, keywords *zs=0* and *zdir='z'* are available. Also, the keyword argument *depthshade* is available to indicate whether to shade the patches in order to give the appearance of depth (default is *True*). This is typically desired in scatter plots. FN)r_in_drawrQrDrE_offset_zorderedrs rrDzPath3DCollection.__init__s@ &  $)&) r44 $rc|j5tj|d5t||ddddddy#1swYxYw#1swYyxYw)NT)rO)_use_zordered_offsetrrhrQri)rFrjrVs rrizPath3DCollection.drawsZ  & & ( '""4$7 ' X& ' ' ' ' ' ' 's!AA A A AA c ||_d|_yrrrs rrzPath3DCollection.set_sort_zposrrc|j|j}t|dkDr|j\}}ng}g}||_t ||t j|||_|j|_ t j|j|_ |j\}}}td|_d|_||_d|_y)a; Set the *z* positions and direction of the paths. Parameters ---------- zs : float or array of floats The location or locations to place the paths in the collection along the *zdir* axis. zdir : {'x', 'y', 'z'} Plane to plot paths orthogonal to. All paths must have the same direction. See `.get_dir_vector` for a description of the values. axlim_clip : bool, default: False Whether to hide paths with a vertex outside the axes view limits. rrNT)r'r(r'r_zdirrr$r)r*_sizes_sizes3dr% _linewidths _linewidths3dr+r,r-r[rYr.s rrEz"Path3DCollection.set_3d_properties s$ ""$""$ w!hhrvvc{2BFF2rc#K|jdy|j}t| |j d||_y#||_wxYwwrA)rP_offsetsrQr2)rF old_offsetrVs rrRz%Path3DCollection._use_zordered_offsetzsJ  ( J G  5 5 6 + *  s7AAA AAc|j"|jrt||jn|}t|dkDr||j}t j ||jSr5r6r;s rr=z3Path3DCollection._maybe_depth_shade_and_sort_colorsr>rc>|jt| SrAr@rBs rrAzPath3DCollection.get_facecolorrCrctj|jdr|jS|j t |SrErGrBs rrJzPath3DCollection.get_edgecolorrKrr)gR@)rtrurvrwrDrirrEr[r_rr#rrrRr=rArJryrzs@rrMrMsm CDU%,'  0d" <   #3J + +?PPPrrMct|trt|_d|_nt|t r t |_||_d|_|j|||y)a/ Convert a `.PatchCollection` into a `.Patch3DCollection` object (or a `.PathCollection` into a `.Path3DCollection` object). Parameters ---------- col : `~matplotlib.collections.PatchCollection` or `~matplotlib.collections.PathCollection` The collection to convert. zs : float or array of floats The location or locations to place the patches in the collection along the *zdir* axis. Default: 0. zdir : {'x', 'y', 'z'} The axis in which to place the patches. Default: "z". See `.get_dir_vector` for a description of the values. depthshade : bool, default: True Whether to shade the patches to give a sense of depth. axlim_clip : bool, default: False Whether to hide patches with a vertex outside the axes view limits. NF) isinstancerrMrVrPrrrrOrE)rr8r)rrGs rpatch_collection_2d_to_3drnsN*#~&( # C ))  COCL"dJ/rceZdZdZdddddfd Zej ejejdZ dZ e jd d Z d Zdfd Zd ZddZdZdZfdZfdZdZdZdZxZS)Poly3DCollectiona A collection of 3D polygons. .. note:: **Filling of 3D polygons** There is no simple definition of the enclosed surface of a 3D polygon unless the polygon is planar. In practice, Matplotlib fills the 2D projection of the polygon. This gives a correct filling appearance only for planar polygons. For all other polygons, you'll find orientations in which the edges of the polygon intersect in the projection. This will lead to an incorrect visualization of the 3D area. If you need filled areas, it is recommended to create them via `~mpl_toolkits.mplot3d.axes3d.Axes3D.plot_trisurf`, which creates a triangulation and thus generates consistent surfaces. averageFN)zsortshade lightsourcerGc|rbt|}|jdd} | t| |||d<|jdd} | t| |||d<| | tdt ||g|i|t |tjr|jdk7r(tdtd|Dr td|j|d|_ ||_ y)a Parameters ---------- verts : list of (N, 3) array-like The sequence of polygons [*verts0*, *verts1*, ...] where each element *verts_i* defines the vertices of polygon *i* as a 2D array-like of shape (N, 3). zsort : {'average', 'min', 'max'}, default: 'average' The calculation method for the z-order. See `~.Poly3DCollection.set_zsort` for details. shade : bool, default: False Whether to shade *facecolors* and *edgecolors*. When activating *shade*, *facecolors* and/or *edgecolors* must be provided. .. versionadded:: 3.7 lightsource : `~matplotlib.colors.LightSource`, optional The lightsource to use when *shade* is True. .. versionadded:: 3.7 axlim_clip : bool, default: False Whether to hide polygons with a vertex outside the view limits. *args, **kwargs All other parameters are forwarded to `.PolyCollection`. Notes ----- Note that this class does a bit of magic with the _facecolors and _edgecolors properties. facecolorsN edgecolorszCYou must provide facecolors, edgecolors, or both for shade to work.r#z)verts must be a list of (N, 3) array-likec3^K|]%}ttj|dk7'yw)rPN)r'r$r).0verts r z,Poly3DCollection.__init__.. s">3rxx~&!+>s+-)_generate_normalsget _shade_colorsr(rQrDrmr$ndarrayndimany set_zsort_codes3dr[) rFrrrrsrtrGrrHnormalsrvrwrVs rrDzPoly3DCollection.__init__sD '.GL$7J%'4(|$ L$7J%'4(|$!j&8 %&& 000 eRZZ (zzQ !LMM>>> !LMM u %r)rqrmaxcH|j||_d|_d|_y)a Set the calculation method for the z-order. Parameters ---------- zsort : {'average', 'min', 'max'} The function applied on the z-coordinates of the vertices in the viewer's coordinate system, to determine the z-order. NT)_zsort_functions _zsortfuncrrY)rFrrs rrzPoly3DCollection.set_zsorts$//6 rz3.10c$|j|SrA) _get_vector)rFrs r get_vectorzPoly3DCollection.get_vector$s ++rc t|r$tj|j\}}}nggg}}}tjt|}tj ||||g|_dgtj|Dcgc] }t|c}}gtt|dd|dd|_ ycc}w)zOptimize points for projection.rNrr) r'r$rronesr%_vecrmapr+ _segslices)rFrr6r7r8rrindicess rrzPoly3DCollection._get_vector(s z?:.00JBBRBBwws2wHHb"b$/0 Kryyj!I7#g,!IJKBCws|WQR[AB"JsC cV|j|t| gd||_y)a Set 3D vertices. Parameters ---------- verts : list of (N, 3) array-like The sequence of polygons [*verts0*, *verts1*, ...] where each element *verts_i* defines the vertices of polygon *i* as a 2D array-like of shape (N, 3). closed : bool, default: True Whether the polygon should be closed by adding a CLOSEPOLY connection at the end. FN)rrQ set_verts_closed)rFrclosedrVs rrzPoly3DCollection.set_verts4s)  "e$ rc8|j|d||_y)z Set 3D vertices with path codes.F)rN)rr)rFrrs rset_verts_and_codesz$Poly3DCollection.set_verts_and_codesGs uU+ rc|jd|_|jdtj||_tj ||_tj||_ d|_ y)NrqT) r'rrr rA _facecolor3drJ _edgecolor3d get_alpha_alpha3drY)rFrGs rrEz"Poly3DCollection.set_3d_propertiesOsb ""$ y!*88>*88>&006  rc ||_d|_yrrrs rrzPoly3DCollection.set_sort_zposZrrc jJjjrj_j rj _jrtgjddj\}}}jjddk(r[tjj|j jd}tjj#||||g}n/tjj#|||g}n j}t%j&|jj(\}}}j*D cgc]} || || || f} } j} j} t-| t-| k7r| j/t-| d} t-| t-| k7r-t-| dk(r| } n| j/t-| d} | rEt1fdt3t5| | | Ddd} t5| \}}__}n8g}tj:d _tj:d _g}j<4|Dcgc]}j<|}}t?j@||n!t?jB|jDt-jt-| k7rj_jFYtj"dgdgjFgd gg}t%j&|jj(}|d dS|jHdkDrtjJ|StjLScc} wcc}w) z< Perform the 3D projection for this object. rr#axisc3K|]N\}\\}}}}}j|jtjj ||g|||fPywrA)rdatar$r5r)ryidxr6r7r8fcecrFs rr{z4Poly3DCollection.do_3d_projection..sV;0S0,>Bx,H"bRUV;sAAc |dSr1r)r s rz3Poly3DCollection.do_3d_projection..s adrT)keyreverserrrrP)'_Ar'_face_is_mapped _facecolorsr_edge_is_mappedrIrr[r=rr9rr$r5 masked_wherer,r%r_proj_transform_vecrdrr'repeatsorted enumerater _facecolors2d _edgecolors2demptyrr rrrrr3rra)rFr6r7r8w_maskedvectxstystzsslxyzlistcfacecedge z_segments_2drridxsrrzvecztranss` rrz!Poly3DCollection.do_3d_projection_s# 77   & & (##$($4$4!##$($4$4!   &B !AB BJBByyq!Q&55--bggtyy|Deekk2r2x"89eekk2r2,/))C223 D S#9=I2CGSWc"g.II!!!! u:W %LLWAL6E u:W %5zQ S\ : ";c'5%89;#D 2M]# IA{D.0BDK!#&!1D !#&!1D D == $378CT]]3'8E8  . .t[% H  $ $T; E t  !SZ /!%!2!2D  ?? &88aS1#'81#>?D//diikkBF!9Q<  XX\66#; 66McJ<9s .N?#OcXt||tj||_yrA)rQ set_facecolorr rArrFrrVs rrzPoly3DCollection.set_facecolor# f%*88>rcXt||tj||_yrA)rQ set_edgecolorr rJrrs rrzPoly3DCollection.set_edgecolorrrctjj|| tj|j |j |_ tj|j|j |_ d|_ y#tttf$rYNwxYw#tttf$r Yd|_ ywxYw)NT) rArtist set_alphar8r9rr:AttributeError TypeError IndexErrorrrIrY)rFalphas rrzPoly3DCollection.set_alphas e,  ' 5 5!!4;;!0D  &44%%t{{ 4D   :6     :6    s#/B /B# B B #CCct|ds9|jj|j_|j t j |jS)Nr)rr9rrdrr$asarrayrrMs rrAzPoly3DCollection.get_facecolorGt_-)),,.DIIK  ! ! #zz$,,--rct|ds9|jj|j_|j t j |jS)Nr)rr9rrdrr$rrrMs rrJzPoly3DCollection.get_edgecolorrr)Tr)rtrurvrwrDr$rqrrrrr deprecatedrrrrrErrrrrrArJryrzs@rrprps(,5E!e<&~::vvvv T__V,, C&  L\? ? ..rrpct|j||\}}t|_|j |||j ||_y)a Convert a `.PolyCollection` into a `.Poly3DCollection` object. Parameters ---------- col : `~matplotlib.collections.PolyCollection` The collection to convert. zs : float or array of floats The location or locations to place the polygons in the collection along the *zdir* axis. Default: 0. zdir : {'x', 'y', 'z'} The axis in which to place the patches. Default: 'z'. See `.get_dir_vector` for a description of the values. N)rrrprVrrEr[)rr8r)rG segments_3drs rpoly_collection_2d_to_3drsJ: MMOR'K$CMK/ COrc`|dk(r|||fS|dk(r|||fS|ddk(rt||||S|||fS)z Reorder coordinates so that 2D *xs*, *ys* can be plotted in the plane orthogonal to *zdir*. *zdir* is normally 'x', 'y' or 'z'. However, if *zdir* starts with a '-' it is interpreted as a compensation for `rotate_axes`. r r!r-) rotate_axesr6r7r8r)s rrrsR s{2rz 2rz aC2r2t,,2rzrc0|dvr|||fS|dvr|||fS|||fS)z Reorder coordinates so that the axes are rotated with *zdir* along the original z axis. Prepending the axis with a '-' does the inverse transform, so *zdir* can be 'x', '-x', 'y', '-y', 'z' or '-z'. )r z-y)z-xr!rrs rrrs8  {2rz  2rz2rzrcxt|dk(st|dk(rtjdStt |t |}d||dzz }tj tj|t|df}tj|ddddf|dddf|zgS)z7Modify the alphas of the color list according to depth.rrrgffffff?rNr#) r'r$zerosrrrrr8r9r)rr8normsatsrgbas rr7r7 s  6{a3r7a<xx SWc"g &D tBx#~ D ??70083r7A, GD ??DBQBKadd):; <.normsGAJ' 'rrr#)r8 LightSourcer$errstaterr directionrrrinverser9rrbcopy) colorrrtrsr,rrrrrs @@rr~r~ps, ))GD X &*BIINN7TNJJ(()* HHUO D xxz##B*$$S!,44 (te %%e,ad eQ ]+e3q!t  Mu%**, M3**s 3EE rs)rr")rr"TF)g:0yE>rA)?rwrenumpyr$ contextlibr matplotlibrrrrr8rr rBr rmatplotlib.collectionsr r r rrmatplotlib.colorsrmatplotlib.patchesrrrrrrr*r=rCr?r}Line2Drrrrrrrrrrrrr rrrrMrnrprrrr7rr|r~rrrrs:   %QQ'$  OD+8dUZZdN/$cU\\cL1&   ' ,: , !(~(V!=e=@5'5p:80pPpPfwP~wPt0>W.~W.t!."  =&+R)X#r