
    hh                       S r SSKJr  SSKrSSKrSSKrSSKrSSKrSSK	r
SSK	JrJrJrJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSK J!r"  SSK#J$r%  SSK&J'r'  SSK(J)r)J*r*  SSK#J+r+  SSK,J-r-  S	S
K.J/r/  S	SK.J0r0  S	SK.J1r1  \Rd                  \Rf                  " S/S/S/S.5       " S S\'5      5       5       r4SS jr5 " S S5      r6g)aR  
axes3d.py, original mplot3d version by John Porter
Created: 23 Sep 2005

Parts fixed by Reinier Heeres <reinier@heeres.eu>
Minor additions by Ben Axelrod <baxelrod@coroware.com>
Significant updates and revisions by Ben Root <ben.v.root@gmail.com>

Module containing Axes3D, an object which can plot 3D objects on a
2D matplotlib figure.
    )defaultdictN)_apicbook
_docstring_preprocess_data)Axes)_axis_method_wrapper_process_plot_format)Bbox)Triangulation   )art3d)proj3d)axis3dxlim3dylim3dzlim3d)xlimylimzlimc                     ^  \ rS rSrSrSrSr\R                  " 5       \	R                  S'   \R                  " 5       \	R                  S'    SSS	S
SSSSSSS.	U 4S jjjrS rS rS rS rS rS r\" SS5      r\" SS5      rS rSU 4S jjrS rSS.S jrSS jr\R6                  U 4S  j5       rS! rS" r\" SS#5      r\" SS$5      r S% r!S& r"SSSSS'.S( jr#SS) jr$SS* jr%  SS+ jr&S, r' SS- jr(SS. jr)SS/ jr*SS0 jr+SSSSSSS1.S2 jjr,SSSSSSS3.S4 jjr-SSSSSSS5.S6 jjr.SSSSSSS7.S8 jjr/\-r0\.r1\/r2S9 r3S: r4S; r5\" SS<5      r6\" S=S>5      r7\" S?S>5      r8\" SS>5      r9\:" S@Rv                  / SQ5      u  \7l        \8l        \9l        \" SSA5      r<\" SSB5      r=\" SSC5      r>\" SSD5      r?\" SSE5      r@\" SSFSGSH0SI9rA\" SSJ5      rB\BR                  (       a%  \B=R                  \CR                  " SK5      -  sl        SL rE  SSM jrFSSN jrG SSOSPSQ\HSR\IR                  4SS jjrKST rLSSU jrMSV rNSW rOSX rPSY rQSZ rRU 4S[ jrSS\ rTS] rUS^ rVS_ rWS` rXSSa jrYSb rZSc r[Sd r\SSe jr]Sf\^Sg\^SR\IR                  4Sh jr_Si r`Sj raSk rb  SSl jrcSm rdSn reSo rfSSp jrgSq rhSriSrjSSr jrkSU 4Ss jjrlSt rm\" SSu5      rnSv roSSSw.U 4Sx jjjrp\prq\	R                  rrSSSy.U 4Sz jjrs\srtSS{SSSS|.S} jruSSSSSS~.S jrvSSw.S jrwSSSSSSS.S jrxSS jry  SS jrzSSSw.S jjr{SS jr|\}" 5       SSSSSS.U 4S jj5       r~\~r\}" 5       SSSSSS.U 4S jj5       rS r\}" 5       SSSS.U 4S jj5       r\r\}" 5       SSSS.U 4S jj5       rSSSw.U 4S jjjr\}" / SQS9 SSSw.U 4S jjj5       r\r\}" 5       SSSw.U 4S jjj5       r\}" 5         SSSw.S jj5       rSU 4S jjr\}" 5       SSSSSS.S j5       r\rSSSSSS.S jr\}" / SQS9     SS j5       rSSSSS.U 4S jjjr\}" 5       SSSS
SSSS.S j5       r\rSrU =r$ )Axes3D)   z
3D Axes object.

.. note::

    As a user, you do not instantiate Axes directly, but use Axes creation
    methods instead; e.g. from `.pyplot` or `.Figure`:
    `~.pyplot.subplots`, `~.pyplot.subplot_mosaic` or `.Figure.add_axes`.
3dxyzr   viewN   ir   perspT)	elevazimroll	shareviewsharez	proj_typefocal_length
box_aspectcomputed_zorderc       	           > Uc  / SQnX@l         X0l        XPl        U R                  X5        Xl        [
        R                  " 5       U l        [
        R                  " 5       U l        Sn[        X/SU-
  SU-
  //5      U l	        [
        R                  " 5       U l
        U R                  U R                  U R                   U R                  5        Xpl        Ub%  U R                  S   R                  X5        SU l        X`l        Ub  U R                  S   R                  X5        UR#                  SS	5      (       a  [%        S
5      e[&        TU ]P  " X/UQ7SU
S.UD6  [&        TU ]U  5         U R-                  5         SU l        SU l        SU l        U R5                  5         SU l        U R9                  5         U R;                  SS9nUR<                  R>                  RA                  SU RB                  5        UR<                  R>                  RA                  SU RD                  5        UR<                  R>                  RA                  SU RF                  5        U RI                  5         U RJ                  RM                  S5        U RN                  RQ                  5       RS                  SS/5      nUS   US   -
  u  U l*        U l+        U RX                  SS R[                  S	5        g)ag	  
Parameters
----------
fig : Figure
    The parent figure.
rect : tuple (left, bottom, width, height), default: None.
    The ``(left, bottom, width, height)`` Axes position.
elev : float, default: 30
    The elevation angle in degrees rotates the camera above and below
    the x-y plane, with a positive angle corresponding to a location
    above the plane.
azim : float, default: -60
    The azimuthal angle in degrees rotates the camera about the z axis,
    with a positive angle corresponding to a right-handed rotation. In
    other words, a positive azimuth rotates the camera about the origin
    from its location along the +x axis towards the +y axis.
roll : float, default: 0
    The roll angle in degrees rotates the camera about the viewing
    axis. A positive angle spins the camera clockwise, causing the
    scene to rotate counter-clockwise.
shareview : Axes3D, optional
    Other Axes to share view angles with.  Note that it is not possible
    to unshare axes.
sharez : Axes3D, optional
    Other Axes to share z-limits with.  Note that it is not possible to
    unshare axes.
proj_type : {'persp', 'ortho'}
    The projection type, default 'persp'.
focal_length : float, default: None
    For a projection type of 'persp', the focal length of the virtual
    camera. Must be > 0. If None, defaults to 1.
    For a projection type of 'ortho', must be set to either None
    or infinity (numpy.inf). If None, defaults to infinity.
    The focal length can be computed from a desired Field Of View via
    the equation: focal_length = 1/tan(FOV/2)
box_aspect : 3-tuple of floats, default: None
    Changes the physical dimensions of the Axes3D, such that the ratio
    of the axis lengths in display units is x:y:z.
    If None, defaults to 4:4:3
computed_zorder : bool, default: True
    If True, the draw order is computed based on the average position
    of the `.Artist`\s along the view direction.
    Set to False if you want to manually control the order in which
    Artists are drawn on top of each other using their *zorder*
    attribute. This can be used for fine-tuning if the automatic order
    does not produce the desired result. Note however, that a manual
    zorder will only be correct for a limited view angle. If the figure
    is rotated by the user, it will look wrong from certain angles.

**kwargs
    Other optional keyword arguments:

    %(Axes3D:kwdoc)s
N)        r,         ?r-   F]tE?r   r   datalimr   auto_add_to_figureFzSauto_add_to_figure is no longer supported for Axes3D. Use fig.add_axes(ax) instead.T)frameonr)   UUUUUU?rootmotion_notify_eventbutton_press_eventbutton_release_eventr   r   r   )r   r   ).initial_aziminitial_elevinitial_rollset_proj_typer*   r   unit
xy_viewLim
zz_viewLim
xy_dataLim
zz_dataLim	view_init_sharez_shared_axesjoin_adjustable
_shareviewpopAttributeErrorsuper__init__set_axis_offset_axis_onMinvM_view_marginautoscale_view	fmt_zdata
mouse_init
get_figurecanvas	callbacks_connect_picklable_on_move_button_press_button_releaseset_top_viewpatchset_linewidthtransLimitsinverted	transform	_pseudo_w	_pseudo_hspinesset_visible)selffigrectr"   r#   r$   r%   r&   r'   r(   r)   r*   argskwargsxymarginpseudo_bbox	__class__s                   M/var/www/html/env/lib/python3.13/site-packages/mpl_toolkits/mplot3d/axes3d.pyrK   Axes3D.__init__<   s   ~ <'D   93.))+))+ 4!"Xq8| < > ? ))+ 	t(($*;*;T=N=NOc"''5(D# f%**4;::*E22 0 
 		
=A	
#
	
EK	
 		  oo4o(

//!4==	2

// $"4"4	6

//"D$8$8	:

  #&&//1;;VV<LM)4Q+a.)H& 	A""5)    c                      SU l         SU l        g )NFT	_axis3donstalere   s    rm   rL   Axes3D.set_axis_off   s    
ro   c                      SU l         SU l        g NTrq   rt   s    rm   rM   Axes3D.set_axis_on   s    
ro   c                 8    U R                   R                  U5      $ )z[
For artists in an Axes, if the zaxis has units support,
convert *z* using zaxis unit type
)zaxisconvert_units)re   r   s     rm   convert_zunitsAxes3D.convert_zunits   s    
 zz''**ro   c                     SU R                   -  nSU R                   -  nSU R                   -  nSU R                   -  nU* U4U R                  l        U* U4U R                  l        SU l        g )Ngffffff?g?T)_distviewLim	intervalx	intervalyrs   )re   xdwlxdwydwlydws        rm   r[   Axes3D.set_top_view   sg     djj DJJdjj DJJ#'%#'%
ro   c                     [         R                  " U 5      U l        [         R                  " U 5      U l        [         R
                  " U 5      U l        g)z5Init 3D Axes; overrides creation of regular X/Y Axes.N)r   XAxisxaxisYAxisyaxisZAxisrz   rt   s    rm   
_init_axisAxes3D._init_axis   s2    \\$'
\\$'
\\$'
ro   c                     U R                   $ )z0Return the ``ZAxis`` (`~.axis3d.Axis`) instance.)rz   rt   s    rm   	get_zaxisAxes3D.get_zaxis   s    zzro   rz   get_gridlinesget_ticklinesc           
          Uu  p#pEpgX$U4X4U4X5U4X%U4X$U4X4U4X5U4X%U4/n[         R                  " XR                  5      $ )z:Return cube with limits from *vals* transformed by self.M.)r   _proj_pointsrN   )	re   valsminxmaxxminymaxyminzmaxzxyzss	            rm   _transformed_cubeAxes3D._transformed_cube   sl    -1*DT"T"T"T"T"T"T"T"$ ""400ro   Fc                 F  > [         R                  " SUS9  [        TU ]  SX#US9  Xl        US;   Ga  U R                  U5      n[        R                  " U R                  R                  5       U R                  R                  5       U R                  R                  5       /5      n[        R                  " USS9nU R                  S:X  a  [        R                  " USS9n[        Xu   U R                   U   -  5      n	XR                   -  n
[#        U R$                  U R&                  U R(                  45       H)  u  pX;   d  M  U" X   X   S	-  -
  X   X   S	-  -   S
SS9  M+     g[        R                  " U R                   5      nXu   X'   1 SkR+                  U5      nU(       al  UR-                  5       n[        R.                  R1                  U R                   U   5      n[        R.                  R1                  X   5      nX==   UU-  -  ss'   U R3                  U5        gg)aA  
Set the aspect ratios.

Parameters
----------
aspect : {'auto', 'equal', 'equalxy', 'equalxz', 'equalyz'}
    Possible values:

    =========   ==================================================
    value       description
    =========   ==================================================
    'auto'      automatic; fill the position rectangle with data.
    'equal'     adapt all the axes to have equal aspect ratios.
    'equalxy'   adapt the x and y axes to have equal aspect ratios.
    'equalxz'   adapt the x and z axes to have equal aspect ratios.
    'equalyz'   adapt the y and z axes to have equal aspect ratios.
    =========   ==================================================

adjustable : None or {'box', 'datalim'}, optional
    If not *None*, this defines which parameter will be adjusted to
    meet the required aspect. See `.set_adjustable` for further
    details.

anchor : None or str or 2-tuple of float, optional
    If not *None*, this defines where the Axes will be drawn if there
    is extra space due to aspect constraints. The most common way to
    specify the anchor are abbreviations of cardinal directions:

    =====   =====================
    value   description
    =====   =====================
    'C'     centered
    'SW'    lower left corner
    'S'     middle of bottom edge
    'SE'    lower right corner
    etc.
    =====   =====================

    See `~.Axes.set_anchor` for further details.

share : bool, default: False
    If ``True``, apply the settings to all shared Axes.

See Also
--------
mpl_toolkits.mplot3d.axes3d.Axes3D.set_box_aspect
)autoequalequalxyequalyzequalxzaspectr   )r   
adjustableanchorsharer   r   r   r   r   axisr/          @TNr   view_margin>   r   r      )r   check_in_listrJ   
set_aspect_aspect_equal_aspect_axis_indicesnparrayr   get_view_intervalr   rz   ptprF   meanmax_box_aspect	enumerate
set_xlim3d
set_ylim3d
set_zlim3d
differencerH   linalgnormset_box_aspect)re   r   r   r   r   
ax_indicesview_intervalsr   r   scaledeltasiset_limr)   remaining_ax_indices	remainingold_diagnew_diagrl   s                     rm   r   Axes3D.set_aspect   s   ` 	M"(	*ju 	 	N??88@JXXtzz'C'C'E'+zz'C'C'E'+zz'C'C'E'G HN &&a0C9,ww~A6COd.>.>z.JJK!1!11"+T__-1__-1__-> #?JA &)B, 6&)B,8N%)t=	#?  XXd&6&67
),
&'0';';J'G$' 4 8 8 :I!yy~~d.>.>z.JKH!yy~~j.DEH)X-@@)##J/= @ro   c                 f    / nUS:X  a  / SQnU$ US:X  a  SS/nU$ US:X  a  SS/nU$ US:X  a  SS/nU$ )	z
Get the indices for which of the x, y, z axes are constrained to have
equal aspect ratios.

Parameters
----------
aspect : {'auto', 'equal', 'equalxy', 'equalxz', 'equalyz'}
    See descriptions in docstring for `.set_aspect()`.
r   r   r   r   r   r   r   r   r   r    )re   r   r   s      rm   r   !Axes3D._equal_aspect_axis_indicesM  sm     
W"J  y QJ
 	 y QJ  y QJro   r   )zoomc                L   US::  a  [        SU S35      eUc  [        R                  " S[        S9nO.[        R                  " U[        S9n[        R
                  " SUS9  US	U-  [        R                  R                  U5      -  -  nU R                  US
S9U l	        S
U l
        g)a  
Set the Axes box aspect.

The box aspect is the ratio of height to width in display
units for each face of the box when viewed perpendicular to
that face.  This is not to be confused with the data aspect (see
`~.Axes3D.set_aspect`). The default ratios are 4:4:3 (x:y:z).

To simulate having equal aspect in data space, set the box
aspect to match your data range in each dimension.

*zoom* controls the overall size of the Axes3D in the figure.

Parameters
----------
aspect : 3-tuple of floats or None
    Changes the physical dimensions of the Axes3D, such that the ratio
    of the axis lengths in display units is x:y:z.
    If None, defaults to (4, 4, 3).

zoom : float, default: 1
    Control overall size of the Axes3D in the figure. Must be > 0.
r   zArgument zoom = z must be > 0N)   r      dtype)r   r   g}?Treverse)
ValueErrorr   asarrayfloatr   check_shaper   r   _roll_to_verticalr   rs   )re   r   r   s      rm   r   Axes3D.set_box_aspectb  s    0 19/v\BCC>ZZ	7FZZe4FT&1
 	,t3biinnV6LLL11&$1G
ro   c                    Uc  U R                  SS9nU R                  5       R                  n[        R                  R                  5       R                  U5      nUR                  UR                  -  nSnUR                  5       nUR                  XVU5      nU R                  UR                  U R                  5       U5      S5        g )NT)originalr   active)get_positionrT   transSubfiguremtransformsr   r=   transformedheightwidthfrozenshrunk_to_aspect_set_positionanchored
get_anchor)re   positiontransbb
fig_aspectr)   pbpb1s           rm   apply_aspectAxes3D.apply_aspect  s    (($(7H
 !00""$007YY)

__!!**=3<<(92>Iro   c                   > U R                  5       (       d  g U R                  5         U R                  R                  U5        SU l        U R                  5       nU R                  U(       a  U" X5      OS 5        U R                  5       U l        [        R                  R                  U R                  5      U l        S U R                   5       nU R                  (       a  [        S U R                   R#                  5        5       5      S-   nU=pV[%        US SS9 H[  n['        U[(        R*                  5      (       a  XWl        US-  nM/  ['        U[.        R0                  5      (       d  MP  Xgl        US-  nM]     OU H  nUR3                  5         M     U R4                  (       a  U R                   R#                  5        H  nUR7                  U5        M     U R                   R#                  5        H  nUR9                  U5        M     U R                   R#                  5        H  nUR                  U5        M     [:        T	U ]  U5        g )NFc              3      #    U  HO  n[        U[        R                  [        R                  45      (       d  M4  UR                  5       (       d  MK  Uv   MQ     g 7fN)
isinstancemcoll
CollectionmpatchesPatchget_visible).0artists     rm   	<genexpr>Axes3D.draw.<locals>.<genexpr>  sB      #&!/v&5#3#3X^^"DE ""$ Fs   3AA	Ac              3   B   #    U  H  nUR                  5       v   M     g 7fr   )
get_zorder)r  r   s     rm   r  r    s"       E,CD !% 1 1,Cs   r   c                 "    U R                  5       $ r   )do_3d_projection)r  s    rm   <lambda>Axes3D.draw.<locals>.<lambda>  s    F4K4K4Mro   T)keyr   )r  _unstale_viewLimr\   draw_frameonget_axes_locatorr   get_projrN   r   r   invrO   	_childrenr*   r   	_axis_mapvaluessortedr   r   r   zorderr   r   r	  rr   	draw_pane	draw_gridrJ   )
re   rendererlocatorcollections_and_patcheszorder_offsetcollection_zorderpatch_zorderr  r   rl   s
            rm   r  Axes3D.draw  s   !! 	

! '')W'$1$G IIMM$&&)	#&!%#&     E,0NN,A,A,C E EGHIM/<< !8%M)-/ fe&6&677$5M%*%77$0M A%L/ 2'') 2 >>--/x( 0 --/x( 0 --/		(# 0 	Xro   c                     U R                  U R                  5       5      nUS   S   US   S   :  nUS   S   US   S   :  nUS   S   US   S   :  nX#U4$ )Nr   r   r   r   )r   
get_w_lims)re   tcxhighyhighzhighs        rm   get_axis_positionAxes3D.get_axis_position  sr    ##DOO$561a2a58#1a2a58#1a2a58#U""ro   c                     g)z;
Not implemented in `~mpl_toolkits.mplot3d.axes3d.Axes3D`.
Nr   )re   xysri   s      rm   update_datalimAxes3D.update_datalim  s     	ro   _get_autoscale_on_set_autoscale_onc                     U R                   $ )z
Retrieve autoscaling margin of the z-axis.

.. versionadded:: 3.9

Returns
-------
zmargin : float

See Also
--------
mpl_toolkits.mplot3d.axes3d.Axes3D.set_zmargin
)_zmarginrt   s    rm   get_zmarginAxes3D.get_zmargin  s     }}ro   c                 b    US::  a  [        S5      eXl        U R                  S5        SU l        g)a  
Set padding of Z data limits prior to autoscaling.

*m* times the data interval will be added to each end of that interval
before it is used in autoscaling.  If *m* is negative, this will clip
the data range instead of expanding it.

For example, if your data is in the range [0, 2], a margin of 0.1 will
result in a range [-0.2, 2.2]; a margin of -0.1 will result in a range
of [0.2, 1.8].

Parameters
----------
m : float greater than -0.5
g      z margin must be greater than -0.5r   TN)r   r0  _request_autoscale_viewrs   )re   ms     rm   set_zmarginAxes3D.set_zmargin  s1      9?@@$$S)
ro   )r   r   r   tightc                   U(       a  Uc  Uc  Ub  [        S5      e[        U5      S:X  a	  US   =n=p#O'[        U5      S:X  a  Uu  pnOU(       a  [        S5      eUcI  UcF  UcC  USLa  [        R                  " SU< S	35        U R                  U R
                  U R                  4$ Ub  U R                  U5        Ub  U R                  U5        Ub  U R                  U5        U R                  XASLUSLUSLS
9  g)z
Set or retrieve autoscaling margins.

See `.Axes.margins` for full documentation.  Because this function
applies to 3D Axes, it also takes a *z* argument, and returns
``(xmargin, ymargin, zmargin)``.
NzECannot pass both positional and keyword arguments for x, y, and/or z.r   r   r   zYMust pass a single positional argument for all margins, or one for each margin (x, y, z).Tzignoring tight=z in get mode)r8  scalexscaleyscalez)	TypeErrorlenr   warn_external_xmargin_ymarginr0  set_xmarginset_ymarginr6  rQ   )re   r   r   r   r8  marginss         rm   rD  Axes3D.margins  s    !- < = =\Q
"A"A\QGA! I J J 9qyD ""_UI\#JK==$-->>=Q=Q=Q$$TM 	 	
ro   c                    Uc  SnSnSnO~US;   a"  U R                  U5        U R                  5       nOSnUS;   a"  U R                  U5        U R                  5       nOSnUS;   a"  U R	                  U5        U R                  5       nOSnU(       a  U R                  SUS9  U(       a  U R                  S	US9  U(       a  U R                  S
US9  gg)z
Convenience method for simple axis view autoscaling.

See `.Axes.autoscale` for full documentation.  Because this function
applies to 3D Axes, *axis* can also be set to 'z', and setting *axis*
to 'both' autoscales all three axes.
NT)r   bothF)r   rG  r   rG  r   )r8  r   r   )set_autoscalex_onget_autoscalex_onset_autoscaley_onget_autoscaley_onset_autoscalez_onget_autoscalez_onr4  )re   enabler   r8  r:  r;  r<  s          rm   	autoscaleAxes3D.autoscale2  s     >FFF}$&&v.//1}$&&v.//1}$&&v.//1((E(:((E(:((E(: ro   c                    [         R                  " U5      [         R                  " U5      :X  a`  U R                  R                  [         R                  " [         R
                  " U5      [         R
                  " U5      /5      U(       + 5        O@U R                  R                  X(       + 5        U R                  R                  X$(       + 5        Ub   U R                  R                  X4(       + 5        U R                  5         g r   )
r   shaper@   update_from_data_xycolumn_stackravelupdate_from_data_xupdate_from_data_yrA   rQ   )re   XYZhad_datas        rm   auto_scale_xyzAxes3D.auto_scale_xyzU  s     88A;"((1+%OO//!bhhqk :;\K OO..q,?OO..q,?=OO..q,?ro   c                    Uc}  U R                   nU(       di  U R                   HY  n[        U[        R                  5      (       a  SnM&  [        U[
        R                  [        R                  45      (       d  MW  Sn  O   O[        U5      =oPl         U(       a  U R                  5       (       a  U R                  R                  u  pxU R                  R                  5       n	U	R                  Xx5      u  pxU R                   S:  a  X-
  U R                   -  n
Xz-  nX-  nU(       d  U	R#                  Xx5      u  pxU R%                  XxU R&                  5        U(       a  U R)                  5       (       a  U R                  R*                  u  pU R,                  R                  5       nUR                  X5      u  pU R.                  S:  a  X-
  U R.                  -  n
X-  nX-  nU(       d  UR#                  X5      u  pU R1                  XU R&                  5        U(       a  U R3                  5       (       a  U R4                  R                  u  pU R6                  R                  5       nUR                  X5      u  pU R8                  S:  a  X-
  U R8                  -  n
X-  nX-  nU(       d  UR#                  X5      u  pU R;                  XU R&                  5        ggg)z
Autoscale the view limits using the data limits.

See `.Axes.autoscale_view` for full documentation.  Because this
function applies to 3D Axes, it also takes a *scalez* argument.
NTFr   )_tightr  r   mimage	AxesImagemlinesLine2Dr   r   boolrJ  r@   r   r   get_major_locatornonsingularr@  view_limits
set_xboundrP   rL  r   r   rA  
set_yboundrN  rA   rz   r0  
set_zbound)re   r8  r:  r;  r<  r`  r  x0x1xlocatordeltay0y1ylocatorz0z1zlocators                    rm   rQ   Axes3D.autoscale_viewc  s@    =[[F"nnF!&&*:*:;;!%#FV]]HNN,KLL!& - $(;.F[d,,..__..FBzz335H))"1FB}}q DMM1!--b5OOBD$5$56d,,..__..FBzz335H))"1FB}}q DMM1!--b5OOBD$5$56d,,..__..FBzz335H))"1FB}}q DMM1!--b5OOBD$5$56 /6ro   c                 x    U R                  5       u  pU R                  5       u  p4U R                  5       u  pVXX4XV4$ )zGet 3D world limits.)
get_xlim3d
get_ylim3d
get_zlim3d)re   r   r   r   r   r   r   s          rm   r"  Axes3D.get_w_lims  s9    __&
__&
__&
4t11ro   c           	          Uc  [         R                  " U5      (       a  Uu  pEU" 5       u  pxUc  UnUc  UnU" [        XE4[        U" 5       5      S9SUS9  g)z
Set 3D axis bounds.
Nr   r   )r   iterabler  re  )	re   	get_boundr   axis_invertedlowerupperr   	old_lower	old_uppers	            rm   _set_bound3dAxes3D._set_bound3d  s[    
 =R[[// LE({	=E=E~tMO/DE{	4ro   c                 j    U R                  U R                  U R                  U R                  XU5        g)a  
Set the lower and upper numerical bounds of the x-axis.

This method will honor axis inversion regardless of parameter order.
It will not change the autoscaling setting (`.get_autoscalex_on()`).

Parameters
----------
lower, upper : float or None
    The lower and upper bounds. If *None*, the respective axis bound
    is not modified.
view_margin : float or None
    The margin to apply to the bounds. If *None*, the margin is handled
    by `.set_xlim`.

See Also
--------
get_xbound
get_xlim, set_xlim
invert_xaxis, xaxis_inverted
N)r  
get_xboundset_xlimxaxis_invertedre   r  r  r   s       rm   ri  Axes3D.set_xbound  +    , 	$//4==$:M:M	5ro   c                 j    U R                  U R                  U R                  U R                  XU5        g)a  
Set the lower and upper numerical bounds of the y-axis.

This method will honor axis inversion regardless of parameter order.
It will not change the autoscaling setting (`.get_autoscaley_on()`).

Parameters
----------
lower, upper : float or None
    The lower and upper bounds. If *None*, the respective axis bound
    is not modified.
view_margin : float or None
    The margin to apply to the bounds. If *None*, the margin is handled
    by `.set_ylim`.

See Also
--------
get_ybound
get_ylim, set_ylim
invert_yaxis, yaxis_inverted
N)r  
get_yboundset_ylimyaxis_invertedr  s       rm   rj  Axes3D.set_ybound  r  ro   c                 j    U R                  U R                  U R                  U R                  XU5        g)a  
Set the lower and upper numerical bounds of the z-axis.
This method will honor axis inversion regardless of parameter order.
It will not change the autoscaling setting (`.get_autoscaley_on()`).

Parameters
----------
lower, upper : float or None
    The lower and upper bounds. If *None*, the respective axis bound
    is not modified.
view_margin : float or None
    The margin to apply to the bounds. If *None*, the margin is handled
    by `.set_zlim`.

See Also
--------
get_zbound
get_zlim, set_zlim
invert_zaxis, zaxis_inverted
N)r  
get_zboundset_zlimzaxis_invertedr  s       rm   rk  Axes3D.set_zbound  s+    * 	$//4==$:M:M	5ro   emitr   r   axminaxmaxc                   Uc6  [         R                  " U5      (       a  Uu  p#OUc  UR                  5       S   nUc  Uc  UR                  5       S   nUb  Ub  [        S5      eUnUb  Ub  [        S5      eUn[         R                  " U5      (       d  [         R                  " U5      (       a  [        SU SU S35      eUc'  [        R                  S   (       a  U R                  nOSnX2-
  U-  n	X)-  nX9-  nUR                  X#XES	9$ )
z
Set 3D axis limits.
r   r   z"Cannot pass both 'lower' and 'min'z"Cannot pass both 'upper' and 'max'zAxis limits z, z cannot be infinitezaxes3d.automarginr  r   )
r   r}  r   r=  isinfr   mplrcParamsrP   _set_lim)
re   r   r  r  r  r   r   r  r  ro  s
             rm   
_set_lim3dAxes3D._set_lim3d   s   
 ={{5!!$u..03=U]**,Q/E  DEEE  DEEE88E??bhhuoo|E7"UG;NOPP||/0"//+-}}U}@@ro   )r  r   r   xminxmaxc                <    U R                  U R                  XX4XVUS9$ )a  
Set the 3D x-axis view limits.

Parameters
----------
left : float, optional
    The left xlim in data coordinates. Passing *None* leaves the
    limit unchanged.

    The left and right xlims may also be passed as the tuple
    (*left*, *right*) as the first positional argument (or as
    the *left* keyword argument).

    .. ACCEPTS: (left: float, right: float)

right : float, optional
    The right xlim in data coordinates. Passing *None* leaves the
    limit unchanged.

emit : bool, default: True
    Whether to notify observers of limit change.

auto : bool or None, default: False
    Whether to turn on autoscaling of the x-axis. *True* turns on,
    *False* turns off, *None* leaves unchanged.

view_margin : float, optional
    The additional margin to apply to the limits.

xmin, xmax : float, optional
    They are equivalent to left and right respectively, and it is an
    error to pass both *xmin* and *left* or *xmax* and *right*.

Returns
-------
left, right : (float, float)
    The new x-axis limits in data coordinates.

See Also
--------
get_xlim
set_xbound, get_xbound
invert_xaxis, xaxis_inverted

Notes
-----
The *left* value may be greater than the *right* value, in which
case the x-axis values will decrease from *left* to *right*.

Examples
--------
>>> set_xlim(left, right)
>>> set_xlim((left, right))
>>> left, right = set_xlim(left, right)

One limit may be left unchanged.

>>> set_xlim(right=right_lim)

Limits may be passed in reverse order to flip the direction of
the x-axis. For example, suppose ``x`` represents depth of the
ocean in m. The x-axis limits might be set like the following
so 5000 m depth is at the left of the plot and the surface,
0 m, is at the right.

>>> set_xlim(5000, 0)
r  )r  r   )re   leftrightr  r   r   r  r  s           rm   r  Axes3D.set_xlim   s,    J tzz4T+6$  P 	Pro   )r  r   r   yminymaxc                <    U R                  U R                  XX4XVUS9$ )a  
Set the 3D y-axis view limits.

Parameters
----------
bottom : float, optional
    The bottom ylim in data coordinates. Passing *None* leaves the
    limit unchanged.

    The bottom and top ylims may also be passed as the tuple
    (*bottom*, *top*) as the first positional argument (or as
    the *bottom* keyword argument).

    .. ACCEPTS: (bottom: float, top: float)

top : float, optional
    The top ylim in data coordinates. Passing *None* leaves the
    limit unchanged.

emit : bool, default: True
    Whether to notify observers of limit change.

auto : bool or None, default: False
    Whether to turn on autoscaling of the y-axis. *True* turns on,
    *False* turns off, *None* leaves unchanged.

view_margin : float, optional
    The additional margin to apply to the limits.

ymin, ymax : float, optional
    They are equivalent to bottom and top respectively, and it is an
    error to pass both *ymin* and *bottom* or *ymax* and *top*.

Returns
-------
bottom, top : (float, float)
    The new y-axis limits in data coordinates.

See Also
--------
get_ylim
set_ybound, get_ybound
invert_yaxis, yaxis_inverted

Notes
-----
The *bottom* value may be greater than the *top* value, in which
case the y-axis values will decrease from *bottom* to *top*.

Examples
--------
>>> set_ylim(bottom, top)
>>> set_ylim((bottom, top))
>>> bottom, top = set_ylim(bottom, top)

One limit may be left unchanged.

>>> set_ylim(top=top_lim)

Limits may be passed in reverse order to flip the direction of
the y-axis. For example, suppose ``y`` represents depth of the
ocean in m. The y-axis limits might be set like the following
so 5000 m depth is at the bottom of the plot and the surface,
0 m, is at the top.

>>> set_ylim(5000, 0)
r  )r  r   )re   bottomtopr  r   r   r  r  s           rm   r  Axes3D.set_ylimh  ,    J tzz6T+6$  P 	Pro   )r  r   r   zminzmaxc                <    U R                  U R                  XX4XVUS9$ )a  
Set the 3D z-axis view limits.

Parameters
----------
bottom : float, optional
    The bottom zlim in data coordinates. Passing *None* leaves the
    limit unchanged.

    The bottom and top zlims may also be passed as the tuple
    (*bottom*, *top*) as the first positional argument (or as
    the *bottom* keyword argument).

    .. ACCEPTS: (bottom: float, top: float)

top : float, optional
    The top zlim in data coordinates. Passing *None* leaves the
    limit unchanged.

emit : bool, default: True
    Whether to notify observers of limit change.

auto : bool or None, default: False
    Whether to turn on autoscaling of the z-axis. *True* turns on,
    *False* turns off, *None* leaves unchanged.

view_margin : float, optional
    The additional margin to apply to the limits.

zmin, zmax : float, optional
    They are equivalent to bottom and top respectively, and it is an
    error to pass both *zmin* and *bottom* or *zmax* and *top*.

Returns
-------
bottom, top : (float, float)
    The new z-axis limits in data coordinates.

See Also
--------
get_zlim
set_zbound, get_zbound
invert_zaxis, zaxis_inverted

Notes
-----
The *bottom* value may be greater than the *top* value, in which
case the z-axis values will decrease from *bottom* to *top*.

Examples
--------
>>> set_zlim(bottom, top)
>>> set_zlim((bottom, top))
>>> bottom, top = set_zlim(bottom, top)

One limit may be left unchanged.

>>> set_zlim(top=top_lim)

Limits may be passed in reverse order to flip the direction of
the z-axis. For example, suppose ``z`` represents depth of the
ocean in m. The z-axis limits might be set like the following
so 5000 m depth is at the bottom of the plot and the surface,
0 m, is at the top.

>>> set_zlim(5000, 0)
r  )r  rz   )re   r  r  r  r   r   r  r  s           rm   r  Axes3D.set_zlim  r  ro   c                 @    [        U R                  R                  5      $ r   )tupler>   r   rt   s    rm   get_xlimAxes3D.get_xlim      T__..//ro   c                 @    [        U R                  R                  5      $ r   )r  r>   r   rt   s    rm   get_ylimAxes3D.get_ylim   r  ro   c                 @    [        U R                  R                  5      $ )aD  
Return the 3D z-axis view limits.

Returns
-------
left, right : (float, float)
    The current z-axis limits in data coordinates.

See Also
--------
set_zlim
set_zbound, get_zbound
invert_zaxis, zaxis_inverted

Notes
-----
The z-axis may be inverted, in which case the *left* value will
be greater than the *right* value.
)r  r?   r   rt   s    rm   get_zlimAxes3D.get_zlim  s    ( T__..//ro   	get_scaler   _set_axes_scaler   a  
        Set the {}-axis scale.

        Parameters
        ----------
        value : {{"linear"}}
            The axis scale type to apply.  3D Axes currently only support
            linear scales; other scales yield nonsensical results.

        **kwargs
            Keyword arguments are nominally forwarded to the scale class, but
            none of them is applicable for linear scales.
        get_ticklocs	set_ticksget_majorticklabelsget_minorticklabelsget_ticklabelsset_ticklabelszAxis.set_tickszAxes3D.set_zticks)doc_sub	axis_datez

        Notes
        -----
        This function is merely provided for completeness, but 3D Axes do not
        support dates for ticks, and so this may not work as expected.
        c                     g)z:Currently not implemented for 3D Axes, and returns *None*.Nr   )re   rh   ri   s      rm   clabelAxes3D.clabelC      ro   c                    SU l         Uc  U R                  nUc  U R                  nUc  U R                  n[        R
                  " [        U R                  5       VVs0 s H  u  pgXv_M	     snnUS9nU(       a.  U R                  S   R                  U 5       Vs1 s H  oiM     n	nOU /n	U	 H  n
Xl
        X*l        X:l        XJl        M     gs  snnf s  snf )a  
Set the elevation and azimuth of the Axes in degrees (not radians).

This can be used to rotate the Axes programmatically.

To look normal to the primary planes, the following elevation and
azimuth angles can be used. A roll angle of 0, 90, 180, or 270 deg
will rotate these views while keeping the axes at right angles.

==========   ====  ====
view plane   elev  azim
==========   ====  ====
XY           90    -90
XZ           0     -90
YZ           0     0
-XY          -90   90
-XZ          0     90
-YZ          0     180
==========   ====  ====

Parameters
----------
elev : float, default: None
    The elevation angle in degrees rotates the camera above the plane
    pierced by the vertical axis, with a positive angle corresponding
    to a location above that plane. For example, with the default
    vertical axis of 'z', the elevation defines the angle of the camera
    location above the x-y plane.
    If None, then the initial value as specified in the `Axes3D`
    constructor is used.
azim : float, default: None
    The azimuthal angle in degrees rotates the camera about the
    vertical axis, with a positive angle corresponding to a
    right-handed rotation. For example, with the default vertical axis
    of 'z', a positive azimuth rotates the camera about the origin from
    its location along the +x axis towards the +y axis.
    If None, then the initial value as specified in the `Axes3D`
    constructor is used.
roll : float, default: None
    The roll angle in degrees rotates the camera about the viewing
    axis. A positive angle spins the camera clockwise, causing the
    scene to rotate counter-clockwise.
    If None, then the initial value as specified in the `Axes3D`
    constructor is used.
vertical_axis : {"z", "x", "y"}, default: "z"
    The axis to align vertically. *azim* rotates about this axis.
share : bool, default: False
    If ``True``, apply the settings to all Axes with shared views.

   N)vertical_axisr   )r   r:   r9   r;   r   check_getitemr   _axis_namesrD   get_siblingsr"   r#   r$   _vertical_axis)re   r"   r#   r$   r  r   idxnamesiblingaxesaxs              rm   rB   Axes3D.view_initG  s    h 
<$$D<$$D<$$D**(1$2B2B(CD(C93TY(CD'

 ((0==dCEC !(GC  ED 6DBGGG -	  E
Es   C
Cc                     [         R                  " SS/US9  US:X  a"  Uc  SnOUS::  a  [        SU S35      eX l        gUS[        R
                  4;  a  [        SU S	U 35      e[        R
                  U l        g)
ax  
Set the projection type.

Parameters
----------
proj_type : {'persp', 'ortho'}
    The projection type.
focal_length : float, default: None
    For a projection type of 'persp', the focal length of the virtual
    camera. Must be > 0. If None, defaults to 1.
    The focal length can be computed from a desired Field Of View via
    the equation: focal_length = 1/tan(FOV/2)
r!   ortho)r'   Nr   r   zfocal_length = z must be greater than 0z must be None for proj_type = )r   r   r   _focal_lengthr   inf)re   r'   r(   s      rm   r<   Axes3D.set_proj_type  s     	GW-C# " ?<. A2 "2 3 3!-D"&&>1 ?<. A99B"E F F!#Dro   arrznp.typing.ArrayLiker   returnc                     U(       a&  [         R                  " XR                  S-
  S-  5      $ [         R                  " XR                  S-
  5      $ )z
Roll arrays to match the different vertical axis.

Parameters
----------
arr : ArrayLike
    Array to roll.
reverse : bool, default: False
    Reverse the direction of the roll.
r   )r   r$   r  )re   r  r   s      rm   r   Axes3D._roll_to_vertical  s@     773!4!4q!8B >??773!4!4q!8::ro   c                    U R                  U R                  5      n[        R                  " / U R	                  5       QU R                  5       QU R                  5       Q7SU06nSU-  n[        R                  " U R                  5      n[        R                  " U R                  5      n[        R                  " U5      [        R                  " U5      -  n[        R                  " U5      [        R                  " U5      -  n[        R                  " U5      nU R                  XgU/5      n	X0R                  U	-  -   n
U R                  U
5      u  pnXl        Xl        Xl        U R$                  [        R&                  :X  aD  [        R(                  " XX5      n[        R*                  " U R                  * U R                  5      nOmX0R                  U	-  U R$                  -  -   n[        R(                  " XUU5      n[        R,                  " U R                  * U R                  U R$                  5      n[        R.                  " X5      n[        R.                  " UU5      nU$ )z?Create the projection matrix from the current viewing position.	pb_aspect      ?)r   r   r   world_transformationrx  ry  rz  r   deg2radr"   r#   cossinr   _calc_view_axes_view_u_view_v_view_wr  r  _view_transformation_uvw_ortho_transformation_persp_transformationdot)re   r)   worldMRelev_radazim_radp0p1p2pseyeuvwviewMprojM	eye_focalM0rN   s                      rm   r  Axes3D.get_proj  s    ++D,<,<=
,, 
__
__
 __
 !	
 * ::dii(::dii(VVHx 00VVHx 00VVH ##RRL1 **r/! &&s+a '33A!AE00$**djjIE JJOd.@.@@@I33A!YGE00$**15151C1CEE
 VVE"FF5"ro   c                    SU l         [        R                  " U5      R                  5       U l        [        R                  " U5      R                  5       U l        [        R                  " U5      R                  5       U l        g)a  
Set the mouse buttons for 3D rotation and zooming.

Parameters
----------
rotate_btn : int or list of int, default: 1
    The mouse button or buttons to use for 3D rotation of the Axes.
pan_btn : int or list of int, default: 2
    The mouse button or buttons to use to pan the 3D Axes.
zoom_btn : int or list of int, default: 3
    The mouse button or buttons to use to zoom the 3D Axes.
N)button_pressedr   
atleast_1dtolist_rotate_btn_pan_btn	_zoom_btn)re   
rotate_btnpan_btnzoom_btns       rm   rS   Axes3D.mouse_init  sZ     # ==4;;=g.557x0779ro   c                 &    U R                  / / / S9  g)z<Disable mouse buttons for 3D rotation, panning, and zooming.)r  r  r  N)rS   rt   s    rm   disable_mouse_rotationAxes3D.disable_mouse_rotation  s    2rB?ro   c                     grw   r   rt   s    rm   can_zoomAxes3D.can_zoom  r  ro   c                     grw   r   rt   s    rm   can_panAxes3D.can_pan  r  ro   c                 
   [         R                  " [        US9  U R                  b  XR                  La  [	        S5      eU R
                  S   R                  X5        Xl        UR                  R                  U R                  l        UR                  R                  U R                  l	        UR                  5       u  p#U R                  X#SUR                  5       S9  UR                  R                  U R                  l        g)z
Share the z-axis with *other*.

This is equivalent to passing ``sharez=other`` when constructing the
Axes, and cannot be used if the z-axis is already being shared with
another Axes.  Note that it is not possible to unshare axes.
otherNzz-axis is already sharedr   Fr  )r   check_isinstancer   rC   r   rD   rE   rz   majorminorr  r  rN  _scale)re   r  rs  rt  s       rm   r&   Axes3D.sharez  s     	fE2<<#\\(A788###D0 ;;,,

 ;;,,

!b5u/F/F/HI!KK..

ro   c                 ^   [         R                  " [        US9  U R                  b  XR                  La  [	        S5      eU R
                  S   R                  X5        Xl        U R                  UR                     nU R                  UR                  UR                  UR                  USS9  g)z
Share the view angles with *other*.

This is equivalent to passing ``shareview=other`` when constructing the
Axes, and cannot be used if the view angles are already being shared
with another Axes.  Note that it is not possible to unshare axes.
r  Nzview angles are already sharedr   Tr"   r#   r$   r  r   )r   r  r   rG   r   rD   rE   r  r  rB   r"   r#   r$   )re   r  r  s      rm   r%   Axes3D.shareview1  s     	fE2??&5+G=>>&!&&t3(()=)=>EJJUZZejj%2$ 	 	@ro   c                 ~  > [         TU ]  5         U R                  [        R                  :X  a  [
        R                  S   U l        OSU l        Sn[        X/SU-
  SU-
  //5      U l	        [        R                  " 5       U l        SU l        U R                  5         U R                  [
        R                  S   5        g )Nzaxes.zmarginr,   r.   r   r2   zaxes3d.grid)rJ   clearr  r   r  r  r  r0  r   r@   r=   rA   rP   rQ   grid)re   rj   rl   s     rm   r$  Axes3D.clearB  s    'LL8DMDM 4!"Xq8| < > ? ))+ 		#,,}-.ro   c                 t   UR                   U :X  a  UR                  U l        UR                  UR                  sU l        U l        U R                  SS9R                  R                  nU(       a!  UR                  5       c  UR                  5         U(       a!  UR                  UR                  U5      5        g g g NTr3   )inaxesbuttonr  xdataydata_sx_syrT   rU   toolbar
_nav_stackpush_currentset_message_mouse_event_to_messagere   eventr/  s      rm   rY   Axes3D._button_pressT  s    <<4"',,D!&ekkDHdhoo4o077??G7--/7$$&##G$C$CE$JK   ro   c                     S U l         U R                  SS9R                  R                  nU(       a!  U R	                  5       c  UR                  5         U(       a!  UR                  UR                  U5      5        g g r(  )r  rT   rU   r/  get_navigate_moder1  r2  r3  r4  s      rm   rZ   Axes3D._button_release^  sf    "//t/,33;; t--/7  " ? ? FG ro   c                    U R                  5       U R                  5       U R                  5       U R                  5       U R	                  5       U R                  5       S.U R                  U R                  U R                  44$ )N)r   autoscalex_onr   autoscaley_onr   autoscalez_on)	r  rJ  r  rL  r  rN  r"   r#   r$   rt   s    rm   	_get_viewAxes3D._get_viewh  sg     MMOd6L6L6NMMOd6L6L6NMMOd6L6L6N
 IItyy$)),	- 	-ro   c                 \    Uu  nu  p4nU R                   " S0 UD6  X0l        X@l        XPl        g )Nr   )setr"   r#   r$   )re   r   propsr"   r#   r$   s         rm   	_set_viewAxes3D._set_viewp  s/    $(!!D5			ro   c                      U R                  U5      $ ! [        [        4 a1    U R                  R	                  5       R
                  nU" U5      nUs $ f = f)z
Return *z* string formatted.  This function will use the
:attr:`fmt_zdata` attribute if it is callable, else will fall
back on the zaxis major formatter
)rR   rI   r=  rz   get_major_formatterformat_data_short)re   r   funcvals       rm   format_zdataAxes3D.format_zdatax  sP    	>>!$$	* 	::113EEDq'CJ	s    >AAc                     SnU R                   U R                  ;   a  U R                  5       nU$ U R                  b  U R	                  XU5      nU$ )z
Return a string giving the current view rotation angles, or the x, y, z
coordinates of the point on the nearest axis pane underneath the mouse
cursor, depending on the mouse button pressed.
 )r  r  _rotation_coordsrN   _location_coords)re   xvyvr  coordss        rm   format_coordAxes3D.format_coord  sU     $"2"22**,F
  VV**28<Fro   c                    [         R                  " U R                  5      n[         R                  " U R                  5      n[         R                  " U R                  5      nSUS SUS SUS S3R                  SS5      nU$ )z)
Return the rotation angles as a string.
z
elevation=z.0fu   °, azimuth=u	   °, roll=   °-u   −)r   _norm_angler"   r#   r$   replace)re   	norm_elev	norm_azim	norm_rollrR  s        rm   rN  Axes3D._rotation_coords  s     %%dii0	%%dii0	%%dii0	yo .&sO ,#C9 GC!12 	 ro   c                    U R                  XU5      u  pEU R                  US   5      nU R                  US   5      nU R                  US   5      nUS:X  a  SU SU SU 3n	U	$ US:X  a  SU SU SU 3n	U	$ US:X  a  SU SU S	U 3n	W	$ )
zI
Return the location on the axis pane underneath the cursor as a string.
r   r   r   zx pane=z, y=z, z=zx=z	, y pane=z	, z pane=)_calc_coordformat_xdataformat_ydatarJ  )
re   rP  rQ  r  r  pane_idxxsyszsrR  s
             rm   rO  Axes3D._location_coords  s     ''9r!u%r!u%r!u%q=rd$rd$rd3F
 	 ]"Yrd$rd3F  ]"T"Yrd3Fro   c                 D   U R                  5       u  pp4pV[        R                  " XU/5      n[        R                  " XEU/5      nU R                  [        R                  :X  a  Sn	OU R                  n	XpR
                  U R                  -  U-  U R                  -  U	-  -   n
U
$ )z:
Returns the current camera location in data coordinates.
g    eA)_get_w_centers_rangesr   r   r  r  r  r   r   )re   cxcyczdxdydzcrr(   r  s              rm   _get_camera_locAxes3D._get_camera_loc  s     "&!;!;!=HHbb\"HHbb\"'L--L,,+a/$2B2BB\QQ
ro   c                    U R                   [        R                  :X  a  SnOSU R                   -  n[        R                  " [        R
                  " XX@R                  5      5      R                  5       nU R                  5       U-
  n/ nU R                  R                  5        H&  nUR                  5       u  pUR                  U
5        M(     [        R                  " S5      n[        S5       H/  nXl   S:X  a  [        R                  X'   M  X\   X|   -
  Xl   -  X'   M1     [        R                  " [!        U5      5      nX   nX^U-  -
  nX4$ )z
Given the 2D view coordinates, find the point on the nearest axis pane
that lies directly below those coordinates. Returns a 3D point in data
coordinates.
r   r  r   r   )r  r   r  r   r   inv_transformrO   rV  rq  r  r  active_paneappendzerosrangeargminabs)re   rP  rQ  r  zvr  vec	pane_locsr   r*  locscalesr   rb  r   r  s                   rm   r_  Axes3D._calc_coord  s    'Bd(((B XXf**22yyABHHJ ""$r) 	NN))+D'')HCS! ,
 !qAv{FF	UY\1SV;		 
 99S[)  )^|ro   r   r   c                 N   [         R                  S   S-  n[         R                  S   U-  nX-  nX#-  nX-  X"-  -   n[        R                  " U5      nSU-   nUSUS-  -   -  nSUSU-  -   -  n	Xi:  a1  [        R                  " [        R                  " SU-
  5      X/5      n
U
$ Xg:  a^  Xv-
  n[        R                  " U[        R                  " X-   X-
  -  5      -
  X/5      n
U
[        R
                  R                  U
5      -  n
U
$ [        R                  " SX-  X&-  /5      n
U
$ )a  
Convert a point (x, y) to a point on a virtual trackball.

This is Ken Shoemake's arcball (a sphere), modified
to soften the abrupt edge (optionally).
See: Ken Shoemake, "ARCBALL: A user interface for specifying
three-dimensional rotation using a mouse." in
Proceedings of Graphics Interface '92, 1992, pp. 151-156,
https://doi.org/10.20380/GI1992.18
The smoothing of the edge is inspired by Gavin Bell's arcball
(a sphere combined with a hyperbola), but here, the sphere
is combined with a section of a cylinder, so it has finite support.
axes3d.trackballsizer   zaxes3d.trackballborderr   r   )r  r  r   sqrtr   r   r   )re   r   r   sbr2rp  raaripdrs               rm   _arcballAxes3D._arcball  s    LL/014LL12Q6		S13YGGBKUQqSMQrT	]6"''!b&/101A  VB!bggqv!&&9::AABA""A  !QS!#'Aro   c                    U R                   (       d  gU R                  5       b  gU R                  c  gUR                  UR                  p2Ub  UR
                  U :w  a  gX R                  -
  X0R                  -
  pTU R                  nU R                  nU R                   U R                  ;   Ga  US:X  a  US:X  a  g[        R                  S   nUS:X  a  [        R                  " U R                  5      n	XW-  * S-  [        R                   " U	5      -  XF-  S-  [        R"                  " U	5      -  -   n
XW-  * S-  [        R"                  " U	5      -  XF-  S-  [        R                   " U	5      -  -
  nU R$                  U
-   nU R&                  U-   nU R                  n	GO[(        R*                  " [        R                  " U R$                  U R&                  U R                  45      6 nUS:X  a  [        R,                  " SU* U-  XF-  /5      n[        R.                  R1                  U5      nU[        R                  S   -  n[)        [        R                   " U5      U[        R"                  " U5      -  U-  5      nOyU R3                  U R                  U-  U R                  U-  5      nU R3                  X&-  X7-  5      nUS:X  a  [(        R5                  UU5      nO[)        SU5      [)        SU* 5      -  nUU-  n[        R6                  " UR9                  5       5      u  pn	U R:                  U R<                     nU R?                  UUU	US	S
9  S	U l         OU R                   U RB                  ;   a  U RD                  RG                  U R                  U R                  /5      u  nnU RI                  UUS5        U RK                  SSURL                  URN                  5        U RQ                  5         O4U R                   U RR                  ;   a  XwU-
  -  nU RU                  UUU5        X#sU l        U l        U RW                  S	S9RX                  R[                  5         g)z
Mouse moving.

By default, button-1 rotates, button-2 pans, and button-3 zooms;
these buttons can be modified via `mouse_init`.
Nr   zaxes3d.mouserotationstyleazel   	trackballr  sphereTr!  r   r3   ).r  r8  rN   r+  r,  r)  r-  r.  ra   rb   r  r  r  r   r  r$   r  r  r"   r#   _Quaternionfrom_cardan_anglesr   r   r   r  rotate_from_torad2degas_cardan_anglesr  r  rB   rs   r	  	transDatar`   	start_pandrag_panr   r   end_panr
  _scale_axis_limitsrT   rU   	draw_idle)re   r5  r   r   rl  rm  r  hstyler$   delevdazimr"   r#   qknkthdqcurrent_vecnew_vecr  pxpyr   s                            rm   rX   Axes3D._on_move  s    ""!!#/ 66>{{EKK19,XXq88|BNNNN $"2"22 Qw27LL!<=Ezz$)),$BFF4L0BD#:bffTl3JJ$BFF4L0BD#:bffTl3JJyy5(yy5(yy22TYY		499$EFH K'!bSUBD!12A*Bcll+ABBB$RVVBZ266":bAB"&--
DHHQJ"GK"mmAC5G((77WM(G4{1{l7SSF#%::a.@.@.B#C D !,,T-@-@AMNN+   DJ   DMM1^^--txx.BCFBNN2r1%MM!T577EGG4LLN   DNN22vJE##E5%8 $(T"))335ro   c                    U R                   nUR                  R                  X44UR                  UR                  4/5      u  u  pgu  pXgsU l        U l        U R                  X4U5        Xh-
  Xy-
  pSnUS:X  a  SnOUS:X  a  Sn
U
S:X  a  US:X  a  g [        R                  " U R                  U R                  U R                  /5      nU* U R                  -  U R                  -  nUR                  [        R                  " XU/5      -  nU R!                  5       u  nnnnnnUU-
  US   -  nUU-
  US   -  nUU-
  US   -  nU R#                  UU-   UU-   S S9  U R%                  UU-   UU-   S S9  U R'                  UU-   UU-   S S9  g )Nr   r   r   r   r   r   )
_pan_starttrans_inverser`   r   r   r-  r.  r  r   r   r  r  r  r   r   Tr"  r   r   r   )re   r*  r  r   r   r  r+  r,  xdata_startydata_startdudvdwr  duvw_projectedr   r   r   r   r   r   rl  rm  rn  s                           rm   r  Axes3D.drag_panf  s    OO56__5N5NVacc133Z 6"22"$( 	qV$$e&9B#:BCZB7rQw HHdllDLL$,,?@B!!!DJJ.rxx55 .2__->*dD$dTk^A..Tk^A..Tk^A.. 	r	4"948r	4"948r	4"948ro   c                    [         R                  " [        R                  " U R                  5      5      n[         R                  " [        R                  " U R
                  5      5      nSU R                  U R                  5      -  n[         R                  " S5      n[        U5      [         R                  S-  :  a  SOSXPR                  '   [        R                  " XXS5      u  pgnXgU4$ )z
Get the unit vectors for the viewing axes in data coordinates.
`u` is towards the right of the screen
`v` is towards the top of the screen
`w` is out of the screen
r  r   r   r  r   )r   r  r   rX  r"   r$   r   r   rw  rz  pir  r   
_view_axes)	re   r  r  roll_radr  Vr  r  r  s	            rm   r  Axes3D._calc_view_axes  s     ::e//		:;::e//		:; $(()9)9::
 HHQK'*8}ruuQw'>A

##CA8aQwro   c                    Uu  pgpUS:X  a3  U R                   R                  S   nU R                   R                  S   n	O8US:X  a2  U R                   R                  S   nU R                   R                  S   n[        R                  " [        Xh/5      U R                   R                  S   U R                   R                  S   5      u  ph[        R                  " [        Xy/5      U R                   R                  S   U R                   R                  S   5      u  pyXh-   S-  n
Xy-   S-  nU R                   R                  S   U R                   R                  S   -   S-  nU R                   R                  S   U R                   R                  S   -   S-  nU R                  XS5        U R                  SSX5        U R                  5         [        Xh-
  5      n[        Xy-
  5      nXR                   R                  S   U R                   R                  S   -
  -  nXR                   R                  S   U R                   R                  S   -
  -  n[        UU5      nUS:X  a  SU-  nU R                  UUU5        g)z
Zoom in or out of the bounding box.

Will center the view in the center of the bounding box, and zoom by
the ratio of the size of the bounding box to the size of the Axes3D.
r   r   r   r   r   Nout)bboxminr   r   clipr  r  r  r  rz  _zoom_data_limits)re   r  	directionmodetwinxtwinystart_xstart_ystop_xstop_yzoom_center_xzoom_center_yax_center_xax_center_yrl  rm  scale_uscale_vr   s                      rm   _set_view_from_bboxAxes3D._set_view_from_bbox  s    .2*63;iimmA&GYY]]1%FS[iimmA&GYY]]1%F ''&'):";"&))--"2DIIMM!4DF''&'):";"&))--"2DIIMM!4DF !)1, )1,yy}}Q'$))--*::A=yy}}Q'$))--*::A=}Q7a{8 !"!"		a(499==+;;<		a(499==+;;< GW% IEueU3ro   c                 ^   [         R                  " XU/5      n[         R                  " XA5      (       d  [         R                  " U R                  U R                  U R
                  /5      nU[         R                  " S5      -  n[         R                  R                  UR                  U-  SS9nU R                  S;   aS  U R                  U R                  5      n[         R                  " [         R                  " XG   S-
  5      5      nXG   U   XG'   U R                  US   US   US   5        g)ar  
Zoom in or out of a 3D plot.

Will scale the data limits by the scale factors. These will be
transformed to the x, y, z data axes based on the current view angles.
A scale factor > 1 zooms out and a scale factor < 1 zooms in.

For an Axes that has had its aspect ratio set to 'equal', 'equalxy',
'equalyz', or 'equalxz', the relevant axes are constrained to zoom
equally.

Parameters
----------
scale_u : float
    Scale factor for the u view axis (view screen horizontal).
scale_v : float
    Scale factor for the v view axis (view screen vertical).
scale_w : float
    Scale factor for the w view axis (view screen depth).
r   r   r   r   r   r   N)r   r   allcloser  r  r  r  r   r   r  r   r   ry  rz  r  )	re   r  r  scale_wr   r  Sax_idxsmin_ax_idxss	            rm   r  Axes3D._zoom_data_limits  s    * 'G45 {{5**$,,dllCDAq	!AIINN1337N3E ||II99$,,G iiu~/A(BC!&!<a%(E!H=ro   c                     U R                  5       u  pEpgpU R                  XGU-  S-  -
  XGU-  S-  -   SS9  U R                  XXU-  S-  -
  XXU-  S-  -   SS9  U R                  XiU-  S-  -
  XiU-  S-  -   SS9  g)aT  
Keeping the center of the x, y, and z data axes fixed, scale their
limits by scale factors. A scale factor > 1 zooms out and a scale
factor < 1 zooms in.

Parameters
----------
scale_x : float
    Scale factor for the x data axis.
scale_y : float
    Scale factor for the y data axis.
scale_z : float
    Scale factor for the z data axis.
r   Nr  )rh  r   r   r   )
re   scale_xscale_yscale_zri  rj  rk  rl  rm  rn  s
             rm   r  Axes3D._scale_axis_limits  s      "&!;!;!= 	Z\)27
1+<4HZ\)27
1+<4HZ\)27
1+<4Hro   c                 v    U R                  5       u  pp4pVX!-   S-  nXC-   S-  nXe-   S-  n	X!-
  n
XC-
  nXe-
  nXxXX4$ )z%Get 3D world centers and axis ranges.r   )r"  )re   r   r   r   r   r   r   ri  rj  rk  rl  rm  rn  s                rm   rh  Axes3D._get_w_centers_ranges  s\     .2__->*Dk1_k1_k1_ kkkrr%%ro   c                 b    Ub  X0R                   l        U R                   R                  " X40 UD6$ )z9
Set zlabel.  See doc for `.set_ylabel` for description.
)rz   labelpadset_label_text)re   zlabelfontdictr  ri   s        rm   
set_zlabelAxes3D.set_zlabel  s.     "*JJzz((DVDDro   c                 N    U R                   R                  nUR                  5       $ )z
Get the z-label text string.
)rz   labelget_text)re   r  s     rm   
get_zlabelAxes3D.get_zlabel#  s      

  ~~ro   c                 B    [        U5      (       a  SnXl        SU l        g)z
Set / unset 3D grid.

.. note::

    Currently, this function does not behave the same as
    `.axes.Axes.grid`, but it is intended to eventually support that
    behavior.
TN)r>  
_draw_gridrs   )re   visibleri   s      rm   r%  Axes3D.grid1  s     v;;G!
ro   c                 N  > [         R                  " / SQUS9  US;   a  [        TU ]  " U40 UD6  US;   ap  [	        U5      nUR                  SS5        UR                  SS5        UR                  SS5        UR                  S	S5        U R                  R                  " S
0 UD6  gg)a  
Convenience method for changing the appearance of ticks and
tick labels.

See `.Axes.tick_params` for full documentation.  Because this function
applies to 3D Axes, *axis* can also be set to 'z', and setting *axis*
to 'both' autoscales all three axes.

Also, because of how Axes3D objects are drawn very differently
from regular 2D Axes, some of these settings may have
ambiguous meaning.  For simplicity, the 'z' axis will
accept settings as if it was like the 'y' axis.

.. note::
   Axes3D currently ignores some of these settings.
)r   r   r   rG  r   )r   r   rG  rH  r  Nr  labeltoplabelbottomr   )r   r   rJ   tick_paramsdictrH   rz   set_tick_params)re   r   ri   zkwrl   s       rm   r  Axes3D.tick_paramsA  s    " 	2>%%G//= v,CGGE4 GGHd#GGJ%GGM4(JJ&&-- !ro   c                 H    U R                  5       u  pU R                  X!SS9  g)z`
Invert the z-axis.

See Also
--------
zaxis_inverted
get_zlim, set_zlim
get_zbound, set_zbound
Nr  )r  r  )re   r  r  s      rm   invert_zaxisAxes3D.invert_zaxis_  s!     mmoc-ro   get_invertedc                 <    U R                  5       u  pX:  a  X4$ X!4$ )z
Return the lower and upper z-axis bounds, in increasing order.

See Also
--------
set_zbound
get_zlim, set_zlim
invert_zaxis, zaxis_inverted
)r  )re   r  r  s      rm   r  Axes3D.get_zboundn  s&     }}=<<ro   )
axlim_clipc                Z   > [         T	U ]  " XU40 UD6n[        R                  " XXV5        U$ )a\  
Add the text *s* to the 3D Axes at location *x*, *y*, *z* in data coordinates.

Parameters
----------
x, y, z : float
    The position to place the text.
s : str
    The text.
zdir : {'x', 'y', 'z', 3-tuple}, optional
    The direction to be used as the z-direction. Default: 'z'.
    See `.get_dir_vector` for a description of the values.
axlim_clip : bool, default: False
    Whether to hide text that is outside the axes view limits.

    .. versionadded:: 3.10
**kwargs
    Other arguments are forwarded to `matplotlib.axes.Axes.text`.

Returns
-------
`.Text3D`
    The created `.Text3D` instance.
)rJ   textr   text_2d_to_3d)
re   r   r   r   r  zdirr   ri   r  rl   s
            rm   r  Axes3D.text~  s/    2 w|A!.v.DT6ro   )r  r   c                  > U R                  5       nU(       a-  [        US   [        5      (       d  UtpSU;   a  [        S5      eOUR	                  SS5      n[
        R                  " XU5      u  pn[        TU ]   " X/UQ70 UD6n	U	 H  n
[        R                  " XX4S9  M     [        R                  " XX5      u  pnU R                  XX5        U	$ )a#  
Plot 2D or 3D data.

Parameters
----------
xs : 1D array-like
    x coordinates of vertices.
ys : 1D array-like
    y coordinates of vertices.
zs : float or 1D array-like
    z coordinates of vertices; either one for all points or one for
    each point.
zdir : {'x', 'y', 'z'}, default: 'z'
    When plotting 2D data, the direction to use as z.
axlim_clip : bool, default: False
    Whether to hide data that is outside the axes view limits.

    .. versionadded:: 3.10
**kwargs
    Other arguments are forwarded to `matplotlib.axes.Axes.plot`.
r   re  z,plot() for multiple values for argument 'zs're  r  r   )has_datar   strr=  rH   r   _broadcast_with_masksrJ   plotr   line_2d_to_3djuggle_axesr]  )re   rc  rd  r  r   rh   ri   r\  re  lineslinerl   s              rm   r  Axes3D.plot  s    , ==?
 
47C00IBv~ NOO  D!$B00<
R5d5f5D$N  &&rr8
BB1ro   r   )wherer  
facecolorsshader   c          	         [         R                  " / SQUS9  U R                  5       n[        R                  " XX4XV5      u  pp4pVU	c  U R
                  R                  5       /n	[        [        R                  " U	5      5      n	Uc  SnOY[        R                  " U[        S9nUR                  UR                  :w  a&  [        SUR                   SUR                   S35      eU[        R                  " U5      ) -  nUS	:X  ao  [         R"                  " [        R$                  " X   XG   45      [        R$                  " X'   XW   45      [        R$                  " X7   Xg   45      S
S9(       a  SnOSnU
c  US:X  a  Sn
OSn
/ n[        R&                  " U5       GH  u  nnXU nX/U nX?U nXOU nX_U nXoU n[)        U5      (       d  M1  US:X  a  [)        U5      S-
  n[        R*                  " USS45      n[        R,                  " USS USS USS 45      USS2SSS24'   [        R,                  " USS USS USS 45      USS2SSS24'   [        R,                  " USS USS USS 45      USS2SSS24'   [        R,                  " USS USS USS 45      USS2SSS24'   U/ UQ-   nGM  US:X  d  GM!  [        R,                  " UUU45      n[        R,                  " USSS2   USSS2   USSS2   45      n[        R$                  " UU4SS9nUR/                  U5        GM     [         R0                  " U4XUS.UD6nU R3                  U5        U R5                  X/X%/X6/U5        U$ )aC  
Fill the area between two 3D curves.

The curves are defined by the points (*x1*, *y1*, *z1*) and
(*x2*, *y2*, *z2*). This creates one or multiple quadrangle
polygons that are filled. All points must be the same length N, or a
single value to be used for all points.

Parameters
----------
x1, y1, z1 : float or 1D array-like
    x, y, and z  coordinates of vertices for 1st line.

x2, y2, z2 : float or 1D array-like
    x, y, and z coordinates of vertices for 2nd line.

where : array of bool (length N), optional
    Define *where* to exclude some regions from being filled. The
    filled regions are defined by the coordinates ``pts[where]``,
    for all x, y, and z pts. More precisely, fill between ``pts[i]``
    and ``pts[i+1]`` if ``where[i] and where[i+1]``. Note that this
    definition implies that an isolated *True* value between two
    *False* values in *where* will not result in filling. Both sides of
    the *True* position remain unfilled due to the adjacent *False*
    values.

mode : {'quad', 'polygon', 'auto'}, default: 'auto'
    The fill mode. One of:

    - 'quad':  A separate quadrilateral polygon is created for each
      pair of subsequent points in the two lines.
    - 'polygon': The two lines are connected to form a single polygon.
      This is faster and can render more cleanly for simple shapes
      (e.g. for filling between two lines that lie within a plane).
    - 'auto': If the points all lie on the same 3D plane, 'polygon' is
      used. Otherwise, 'quad' is used.

facecolors : list of :mpltype:`color`, default: None
    Colors of each individual patch, or a single color to be used for
    all patches.

shade : bool, default: None
    Whether to shade the facecolors. If *None*, then defaults to *True*
    for 'quad' mode and *False* for 'polygon' mode.

axlim_clip : bool, default: False
    Whether to hide data that is outside the axes view limits.

    .. versionadded:: 3.10

**kwargs
    All other keyword arguments are passed on to `.Poly3DCollection`.

Returns
-------
`.Poly3DCollection`
    A `.Poly3DCollection` containing the plotted polygons.

)r   quadpolygon)r  NTr   zwhere size (z) does not match size ()r   g-q=)atolr  r  Fr   r   r   r  r   r   r   )r  r  r   )r   r   r  r   r
  _get_patches_for_fillget_next_colorlistmcolorsto_rgba_arrayr   r   re  sizer   isnanr   _all_points_on_planeconcatenatecontiguous_regionsr>  emptyrU  rv  Poly3DCollectionadd_collectionr]  )re   rm  rq  rt  x2y2z2r  r  r  r  r   ri   r\  polysidx0idx1x1iy1iz1ix2iy2iz2i	n_polys_ipolys_iline1line2polypolycs                                rm   fill_betweenAxes3D.fill_between  sn   | 	6TB==?!&!<!<RRR!T44CCEFJ'//
;<
=EJJuD1EzzRWW$ <

| <**,''!"5 6 6"%6>))"..")RY9O*P*,..")RY9O*P*,..")RY9O*P/46 !=v~2259JD$$-C$-C$-C$-C$-C$-Cs88v~HqL	((Iq!#45#%??CHc#2hCR3Q#R1a #%??CGSWc!"g3N#O1a #%??CGSWc!"g3N#O1a #%??CHc#2hCR3Q#R1a 
'
*"c38TrTC"Is4R4y(IJ~~uen1=T"1 :4 &&u H2<H@FHE"RHrh(Cro   )r   vminvmaxlightsourcer   c                   U R                  5       n
UR                  S:w  a  [        S5      e[        R                  " U5      n[
        R                  " XU5      u  pnUR                  u  pSU	;   =(       d    SU	;   nSU	;   =(       d    SU	;   nU(       a  U(       a  [        S5      eU	R                  SS5      nU	R                  SS5      nU	R                  SS	5      nU	R                  SS	5      n[        R                  S
   (       a  UnOU(       + nU(       aX  [        [        [
        R                  " UU-  5      S5      5      n[        [        [
        R                  " UU-  5      S5      5      nU	R                  SS5      nU	R                  SS5      nU	R                  SUSL 5      nUc  [        S5      e/ nUS-
  U-  S:X  aO  US-
  U-  S:X  aC  Uc@  [
        R                  " XU4 Vs/ s H  n[        R                   " UUU5      PM     snSS9nGO[#        [%        SUS-
  U5      5      US-
  /-   n[#        [%        SUS-
  U5      5      US-
  /-   n/ n[&        R(                  " U5       H  u  nn[&        R(                  " U5       H  u  nnXU4 Vs/ s H(  n[        R*                  " UUUS-   2UUS-   24   5      PM*     n n[
        R,                  " U 5      R.                  n UR1                  U 5        Uc  Ms  UR1                  UU   U   5        M     M     [3        U[
        R4                  5      (       a)  [
        R6                  " U5      R9                  5       (       d  / n!/ n"[&        R:                  " UU5       Ht  u  n#n$[
        R,                  " U#5      [
        R6                  " U#5      R9                  SS9   n%[=        U%5      (       d  MR  U!R1                  U%5        U"R1                  U$5        Mv     U!nUb  U"nUb  [>        R@                  " U4UUUXxS.U	D6n&GO@U(       a  [>        R@                  " U4SU0U	D6n&[3        U[
        R4                  5      (       a  US   RC                  SS9n'O<[
        R,                  " U V s/ s H  n U SS2S4   RC                  5       PM     sn 5      n'U&RE                  U'5        Uc  Ub  U&RG                  XV5        Ub  U&RI                  U5        OuU	R                  SS5      n(U(c  U RJ                  RM                  5       n([
        R,                  " [N        RP                  " U(5      5      n([>        R@                  " U4U(UUUS.U	D6n&U RS                  U&5        U RU                  XX:5        U&$ s  snf s  snf s  sn f )a  
Create a surface plot.

By default, it will be colored in shades of a solid color, but it also
supports colormapping by supplying the *cmap* argument.

.. note::

   The *rcount* and *ccount* kwargs, which both default to 50,
   determine the maximum number of samples used in each direction.  If
   the input data is larger, it will be downsampled (by slicing) to
   these numbers of points.

.. note::

   To maximize rendering speed consider setting *rstride* and *cstride*
   to divisors of the number of rows minus 1 and columns minus 1
   respectively. For example, given 51 rows rstride can be any of the
   divisors of 50.

   Similarly, a setting of *rstride* and *cstride* equal to 1 (or
   *rcount* and *ccount* equal the number of rows and columns) can use
   the optimized path.

Parameters
----------
X, Y, Z : 2D arrays
    Data values.

rcount, ccount : int
    Maximum number of samples used in each direction.  If the input
    data is larger, it will be downsampled (by slicing) to these
    numbers of points.  Defaults to 50.

rstride, cstride : int
    Downsampling stride in each direction.  These arguments are
    mutually exclusive with *rcount* and *ccount*.  If only one of
    *rstride* or *cstride* is set, the other defaults to 10.

    'classic' mode uses a default of ``rstride = cstride = 10`` instead
    of the new default of ``rcount = ccount = 50``.

color : :mpltype:`color`
    Color of the surface patches.

cmap : Colormap, optional
    Colormap of the surface patches.

facecolors : list of :mpltype:`color`
    Colors of each individual patch.

norm : `~matplotlib.colors.Normalize`, optional
    Normalization for the colormap.

vmin, vmax : float, optional
    Bounds for the normalization.

shade : bool, default: True
    Whether to shade the facecolors.  Shading is always disabled when
    *cmap* is specified.

lightsource : `~matplotlib.colors.LightSource`, optional
    The lightsource to use when *shade* is True.

axlim_clip : bool, default: False
    Whether to hide patches with a vertex outside the axes view limits.

    .. versionadded:: 3.10

**kwargs
    Other keyword arguments are forwarded to `.Poly3DCollection`.
r   !Argument Z must be 2-dimensional.rstridecstridercountccount.Cannot specify both stride and count argumentsr  2   _internal.classic_moder   r  Ncmapr  zshade cannot be None.r   r  r   )
edgecolorsr  r  r<  r   r   ).r   color)r  r  r<  r   )+r  ndimr   r   _to_unmasked_float_arrayr   broadcast_arraysrS  rH   r  r  intr   ceilgetstack_array_patch_perimetersr  rx  	itertoolspairwise_array_perimeterr   r  rv  r   ndarrayisfiniteallzip_longestr>  r   r$  r   	set_arrayset_climset_norm
_get_linesr  r  to_rgbar%  r]  ))re   rY  rZ  r[  r   r:  r;  r<  r   ri   r\  rowscols
has_stride	has_countr?  r@  rA  rB  compute_stridesfcolorsrF  r  colsetr  r)  row_indscol_indsrsrs_nextcscs_nextr  	new_polys
new_colsetr  colnew_polyr7  avg_zrH  s)                                            rm   plot_surfaceAxes3D.plot_surfaceM  s   V ==?66Q;@AA**1-%%aA.aWW
&(?I,?
&<(f*<	)MNN**Y+**Y+Hb)Hb)<<01 (O #-nO#bggdVm4a89G#bggdVm4a89G**\40zz&$'

7DDL1=4551H1$1H1$?HH)%#Q ..q'7C#%E E!T!VW56$q&AHE!T!VW56$q&AHE(11(;G#,#5#5h#?KB #$ "+A ..qGAIr'!)|1K/LM!*   "BLL$*gbk"o6 $@  <" %,,BKK4F4J4J4L4LIJ
 $//v>388A;r{{1~'9'9q'9'ABx==$$X.%%c*	 ? E"#
 **J"(V5'JBHJE **5RZR6RE%,,f***3E!BEb"QT(--/E!BCOOE"4#3t*t$JJw-E}668HHW__U34E**1"'u+%1)/1E 	E"A!.Y%\ "Cs   '"U?/V !V	c                   U R                  5       nUR                  S:w  a  [        S5      e[        R                  " XU5      u  pnUR
                  u  pxSU;   =(       d    SU;   n	SU;   =(       d    SU;   n
U	(       a  U
(       a  [        S5      eUR                  SS5      nUR                  SS5      nUR                  SS	5      nUR                  SS	5      n[        R                  S
   (       ap  U
(       ah  U(       a+  [        [        [        R                  " X}-  5      S5      5      OSnU(       a+  [        [        [        R                  " X-  5      S5      5      OSnOoU	(       dh  U(       a+  [        [        [        R                  " X}-  5      S5      5      OSnU(       a+  [        [        [        R                  " X-  5      S5      5      OSn[        R                  " U5      [        R                  " U5      [        R                  " U5      nnnU(       a1  [        [        SX{5      5      nUS:  a  US   US-
  :w  a	  UUS-
  /-  nO/ nU(       a1  [        [        SX5      5      nUS:  a  US   US-
  :w  a	  UUS-
  /-  nO/ nUS:X  a  US:X  a  [        S5      eUR                  S:X  a  / n/ nU Vs/ s H  nUU   PM
     nnU Vs/ s H  nUU   PM
     nnU Vs/ s H  nUU   PM
     nnU Vs/ s H  nUU   PM
     nnU Vs/ s H  nUU   PM
     nnU Vs/ s H  nUU   PM
     nn[!        UUU5       VVVs/ s H  u  nnn[        [!        UUU5      5      PM     snnn[!        UUU5       VVVs/ s H  u  nnn[        [!        UUU5      5      PM     snnn-   n["        R$                  " U4SU0UD6nU R'                  U5        U R)                  XX65        U$ s  snf s  snf s  snf s  snf s  snf s  snf s  snnnf s  snnnf )at  
Plot a 3D wireframe.

.. note::

   The *rcount* and *ccount* kwargs, which both default to 50,
   determine the maximum number of samples used in each direction.  If
   the input data is larger, it will be downsampled (by slicing) to
   these numbers of points.

Parameters
----------
X, Y, Z : 2D arrays
    Data values.

axlim_clip : bool, default: False
    Whether to hide lines and patches with vertices outside the axes
    view limits.

    .. versionadded:: 3.10

rcount, ccount : int
    Maximum number of samples used in each direction.  If the input
    data is larger, it will be downsampled (by slicing) to these
    numbers of points.  Setting a count to zero causes the data to be
    not sampled in the corresponding direction, producing a 3D line
    plot rather than a wireframe plot.  Defaults to 50.

rstride, cstride : int
    Downsampling stride in each direction.  These arguments are
    mutually exclusive with *rcount* and *ccount*.  If only one of
    *rstride* or *cstride* is set, the other defaults to 1.  Setting a
    stride to zero causes the data to be not sampled in the
    corresponding direction, producing a 3D line plot rather than a
    wireframe plot.

    'classic' mode uses a default of ``rstride = cstride = 1`` instead
    of the new default of ``rcount = ccount = 50``.

**kwargs
    Other keyword arguments are forwarded to `.Line3DCollection`.
r   r>  r?  r@  rA  rB  rC  r   rD  rE  r   r  z*Either rstride or cstride must be non zeror   )r  rI  r   r   rK  rS  rH   r  r  rL  r   rM  	transposer  rx  r  zipr   Line3DCollectionr%  r]  ) re   rY  rZ  r[  r   ri   r\  r]  r^  r_  r`  r?  r@  rA  rB  tXtYtZriiciir   xlinesylineszlinestxlinestylinestzlinesxlylzlr  linecs                                    rm   plot_wireframeAxes3D.plot_wireframe	  s   X ==?66Q;@AA%%aA.aWW
&(?I,?
&<(f*<	)MNN**Y***Y*Hb)Hb)<<01 AG#c"''$-"8!<=QAG#c"''$-"8!<=Q AG#c"''$-"8!<=QAG#c"''$-"8!<=Q
 \\!_bll1or||ABuQ./CaxCGq1QxCuQ./CaxCGq1QxCa<GqLIJJ 66Q;CC #$1!A$$ #$1!A$$ #$1!A$$"%&#Q2a5#&"%&#Q2a5#&"%&#Q2a5#& $'vvv#>@#>ZRR s2r2'#>@ $'w#AC#AZRR RR)#ACC
 &&uNNvNE"A!.# %$$&&&@Cs0   3O O%O*2O/O4O9>$O>7$P
)rH  r   r:  r;  r<  r   c                   U R                  5       n	Uc  U R                  R                  5       n[        R                  " [
        R                  " U5      5      nUR                  SS5      n
UR                  SU
SL 5      n[        R                  " U0 UD6u  pn UR                  S5      n[        R                  " U5      nUR                  5       nUR                  U   nUR                  U   nX   n[        R                   " UUU4SS9nU
(       ar  ["        R$                  " U/UQ7SU0UD6nUSS2SS2S4   R'                  S	S9nUR)                  U5        Uc  Ub  UR+                  X45        Ub  UR-                  U5        O["        R$                  " U/UQ7XXS
.UD6nU R/                  U5        U R1                  UR                  UR                  X5        U$ ! [         a    Utp GN@f = f)a  
Plot a triangulated surface.

The (optional) triangulation can be specified in one of two ways;
either::

  plot_trisurf(triangulation, ...)

where triangulation is a `~matplotlib.tri.Triangulation` object, or::

  plot_trisurf(X, Y, ...)
  plot_trisurf(X, Y, triangles, ...)
  plot_trisurf(X, Y, triangles=triangles, ...)

in which case a Triangulation object will be created.  See
`.Triangulation` for an explanation of these possibilities.

The remaining arguments are::

  plot_trisurf(..., Z)

where *Z* is the array of values to contour, one per point
in the triangulation.

Parameters
----------
X, Y, Z : array-like
    Data values as 1D arrays.
color
    Color of the surface patches.
cmap
    A colormap for the surface patches.
norm : `~matplotlib.colors.Normalize`, optional
    An instance of Normalize to map values to colors.
vmin, vmax : float, optional
    Minimum and maximum value to map.
shade : bool, default: True
    Whether to shade the facecolors.  Shading is always disabled when
    *cmap* is specified.
lightsource : `~matplotlib.colors.LightSource`, optional
    The lightsource to use when *shade* is True.
axlim_clip : bool, default: False
    Whether to hide patches with a vertex outside the axes view limits.

    .. versionadded:: 3.10
**kwargs
    All other keyword arguments are passed on to
    :class:`~mpl_toolkits.mplot3d.art3d.Poly3DCollection`

Examples
--------
.. plot:: gallery/mplot3d/trisurf3d.py
.. plot:: gallery/mplot3d/trisurf3d_2.py
NrF  r  r[  r  r   r   r   r   )r  r<  r  r   )r  r[  r  r   r   r  r\  rN  rH   r   get_from_args_and_kwargsKeyErrorr   get_masked_trianglesr   r   rO  r   r$  r   rX  rY  rZ  r%  r]  )re   rH  r   r:  r;  r<  r   rh   ri   r\  rF  r  trir   	trianglesxtytztvertsr7  rn  s                        rm   plot_trisurfAxes3D.plot_trisurf	  s   r ==? =OO224E/0zz&$'

7DDL1 22DCFC 	6	

3A JJqM,,.	UU9UU9\"b"B/**5 L4 L6@LDJLE !Q'N''Q'/EOOE"4#3t*t$**CC$) C;ACE 	E"CEE355!6;  	HA	s   G G*)G*   c                    UR                   S   UR                   S   -
  S-  n/ n/ n[        UR                   5       GHh  u  pgUR                  5       U   n/ UR                  5       Qn	UR	                  5       U   n
[
        R                  " XU-
  5      n[
        R                  " XU-   5      n[        US   5      (       d  M  [        [        [        US   5      U-  5      S5      n[        US   5      S-
  US-
  -  nUR                  [        [        U5      S-
  5       Vs/ s HU  nUS   [        X-  5         US   [        US-   U-  5         US   [        US-   U-  5         US   [        X-  5         4PMW     sn5        UR                  U
/[        U5      S-
  -  5        GMk     U R                  [
        R                  " [        R                  " U5      XUSS95        UR!                  5         gs  snf )z$
Extend a contour in 3D by creating
r   r   r   T)r  rG  r  N)levelsr   	get_paths_iter_connected_componentsget_edgecolorr   _paths_to_3d_segmentsr>  r   roundextendrx  add_collection3dr$  r   r   remove)re   csetstridern  	polyvertscolorsr  levelpathsubpathsrH  r  botnstepsstepsizer   s                   rm   _3d_extend_contourAxes3D._3d_extend_contour	  s   
 kk!nt{{1~-2	#DKK0JC>>#C(D;88:;H&&(-E--h
CC--h
CCs1v;;s3q6{V34a8FCFaFQJ7H uV}q013 2A Qal+,c!fUAEX;M5N.OQq1u012CF5;N4OQ13 4 MM5'U6]Q%678 1 	e44HHY> 	? 	3s    AG3
c                     SU-   nU(       a  U R                  X5        g [        R                  " Xb  UOUR                  UUS9  g )NrW  r  )r  r   collection_2d_to_3dr  )re   r  extend3dr  r  offsetr   s          rm   add_contour_setAxes3D.add_contour_set
  s?     Tz##D1%%#54;;T%'ro   c                &    U R                  XUUS9  g )Nr  r  r   )_add_contourf_set)re   r  r  r  r   s        rm   add_contourf_setAxes3D.add_contourf_set
  s    tv*4 	 	6ro   c                 $   SU-   nUR                   SS [        R                  " UR                   5      S-  -   nUR                  (       aN  UR                   S   [        R                  " UR                   SS 5      S-  -
  n[        R                  " USU5      nUR
                  (       aL  UR                   S   [        R                  " UR                   SS 5      S-  -   n[        R                  " XW5      n[        R                  " Xb  UOUUUS9  U$ )z]
Returns
-------
levels : `numpy.ndarray`
    Levels at which the filled contours are added.
rW  Nr  r   r   r  )	r  r   diff_extend_mininsert_extend_maxrv  r   r  )re   r  r  r  r   	midpoints	min_level	max_levels           rm   r  Axes3D._add_contourf_set!
  s     TzKK$rwwt{{';a'??	ARa)AA)EEI		)Q	:IB"''$++bc2B*Ca*GGI		)7I!!1Vyt!	# ro   )r  r  r  r  r   c                   > U R                  5       n[        R                  " XX65      u  pn[        TU ]  " XU/U	Q70 U
D6nU R                  XXVXx5        U R                  XX;5        U$ )a  
Create a 3D contour plot.

Parameters
----------
X, Y, Z : array-like,
    Input data. See `.Axes.contour` for supported data shapes.
extend3d : bool, default: False
    Whether to extend contour in 3D.
stride : int, default: 5
    Step size for extending contour.
zdir : {'x', 'y', 'z'}, default: 'z'
    The direction to use.
offset : float, optional
    If specified, plot a projection of the contour lines at this
    position in a plane normal to *zdir*.
axlim_clip : bool, default: False
    Whether to hide lines with a vertex outside the axes view limits.

    .. versionadded:: 3.10
data : indexable object, optional
    DATA_PARAMETER_PLACEHOLDER

*args, **kwargs
    Other arguments are forwarded to `matplotlib.axes.Axes.contour`.

Returns
-------
matplotlib.contour.QuadContourSet
)r  r   rotate_axesrJ   contourr  r]  )re   rY  rZ  r[  r  r  r  r  r   rh   ri   r\  jXjYjZr  rl   s                   rm   r  Axes3D.contour8
  sh    D ==?&&qQ5
wrr;D;F;TV6NA!.ro   c                  > U R                  5       n[        R                  " U0 UD6u  pnU	R                  n
U	R                  nSU;   a  UR                  S5      nOUtp[        R                  " XX5      u  pn[        XU	R                  U	R                  5      n	[        TU ],  " X/UQ70 UD6nU R                  UXX4U5        U R                  XX5        U$ )a  
Create a 3D contour plot.

.. note::
    This method currently produces incorrect output due to a
    longstanding bug in 3D PolyCollection rendering.

Parameters
----------
X, Y, Z : array-like
    Input data. See `.Axes.tricontour` for supported data shapes.
extend3d : bool, default: False
    Whether to extend contour in 3D.
stride : int, default: 5
    Step size for extending contour.
zdir : {'x', 'y', 'z'}, default: 'z'
    The direction to use.
offset : float, optional
    If specified, plot a projection of the contour lines at this
    position in a plane normal to *zdir*.
axlim_clip : bool, default: False
    Whether to hide lines with a vertex outside the axes view limits.

    .. versionadded:: 3.10
data : indexable object, optional
    DATA_PARAMETER_PLACEHOLDER
*args, **kwargs
    Other arguments are forwarded to `matplotlib.axes.Axes.tricontour`.

Returns
-------
matplotlib.tri._tricontour.TriContourSet
r[  )r  r   r  r   r   rH   r   r  r  maskrJ   
tricontourr  r]  )re   r  r  r  r  r   rh   ri   r\  r  rY  rZ  r[  r  r  r  r  rl   s                    rm   r  Axes3D.tricontoure
  s    J ==?)BB!!6EEEE&=

3A HA&&qQ5
BCMM388<w!#;D;F;T8T:NA!.ro   c                     SUSUSX4U0nS Vs/ s H3  n[         R                  " Xx   5      [         R                  " Xx   5      4PM5     n	nU R                  " / U	QUP76   g s  snf )Nr   r   r   r   )r   nanminnanmaxr]  )
re   rY  rZ  r[  r  r  r\  dim_valsdimlimitss
             rm   _auto_scale_contourfAxes3D._auto_scale_contourf
  sp     CC&9 -.,c 99X]+RYYx}-EF, 	 ..V.X..s   :Ar  c                   > U R                  5       n	[        R                  " XX45      u  pn[        TU ]  " XU/UQ70 UD6nU R                  XXV5      nU R                  XX4X5        U$ )a  
Create a 3D filled contour plot.

Parameters
----------
X, Y, Z : array-like
    Input data. See `.Axes.contourf` for supported data shapes.
zdir : {'x', 'y', 'z'}, default: 'z'
    The direction to use.
offset : float, optional
    If specified, plot a projection of the contour lines at this
    position in a plane normal to *zdir*.
axlim_clip : bool, default: False
    Whether to hide lines with a vertex outside the axes view limits.

    .. versionadded:: 3.10
data : indexable object, optional
    DATA_PARAMETER_PLACEHOLDER
*args, **kwargs
    Other arguments are forwarded to `matplotlib.axes.Axes.contourf`.

Returns
-------
matplotlib.contour.QuadContourSet
)r  r   r  rJ   contourfr  r  )re   rY  rZ  r[  r  r  r   rh   ri   r\  r  r  r  r  r  rl   s                  rm   r  Axes3D.contourf
  sj    8 ==?&&qQ5
w<T<V<''FG!!!Bro   c                  > U R                  5       n[        R                  " U0 UD6u  ptnUR                  nUR                  n	SU;   a  UR                  S5      n
OUtp[        R                  " XX5      u  pn[        XUR                  UR                  5      n[        TU ],  " X}/UQ70 UD6nU R                  XX#5      nU R                  XXX5        U$ )a+  
Create a 3D filled contour plot.

.. note::
    This method currently produces incorrect output due to a
    longstanding bug in 3D PolyCollection rendering.

Parameters
----------
X, Y, Z : array-like
    Input data. See `.Axes.tricontourf` for supported data shapes.
zdir : {'x', 'y', 'z'}, default: 'z'
    The direction to use.
offset : float, optional
    If specified, plot a projection of the contour lines at this
    position in a plane normal to zdir.
axlim_clip : bool, default: False
    Whether to hide lines with a vertex outside the axes view limits.

    .. versionadded:: 3.10
data : indexable object, optional
    DATA_PARAMETER_PLACEHOLDER
*args, **kwargs
    Other arguments are forwarded to
    `matplotlib.axes.Axes.tricontourf`.

Returns
-------
matplotlib.tri._tricontour.TriContourSet
r[  )r  r   r  r   r   rH   r   r  r  r  rJ   tricontourfr  r  )re   r  r  r   rh   ri   r\  r  rY  rZ  r[  r  r  r  r  r  rl   s                   rm   r  Axes3D.tricontourf
  s    @ ==?)BB!!6EEEE&=

3A HA&&qQ5
BCMM388<w"3<T<V<''FG!!!Bro   c                  > U R                  5       n[        R                  " U5      nUR                  (       a  [        R                  " U5      OSn[        U5      [        R                  L a(  [        R                  " XUUS9  UR                  U5        O[        U5      [        R                  L a(  [        R                  " XUUS9  UR                  U5        OC[        U5      [        R                  L a'  [        R                  " XUUS9  UR                  U5        U(       a  [        U[        R                   5      (       a?  U R"                  " [        R$                  " UR&                  5      R)                  5       SU06  O_[        U[        R*                  5      (       a   U R"                  " UR,                  SS SU06  O [        U[        R.                  5      (       a   [0        T
U ]e  U5      n	U	$ )a  
Add a 3D collection object to the plot.

2D collection types are converted to a 3D version by
modifying the object and adding z coordinate information,
*zs* and *zdir*.

Supported 2D collection types are:

- `.PolyCollection`
- `.LineCollection`
- `.PatchCollection` (currently not supporting *autolim*)

Parameters
----------
col : `.Collection`
    A 2D collection object.
zs : float or array-like, default: 0
    The z-positions to be used for the 2D objects.
zdir : {'x', 'y', 'z'}, default: 'z'
    The direction to use for the z-positions.
autolim : bool, default: True
    Whether to update the data limits.
axlim_clip : bool, default: False
    Whether to hide the scatter points outside the axes view limits.

    .. versionadded:: 3.10
r   r  r\  Nr  )r  r   r  r  r  typer   PolyCollectionr   poly_collection_2d_to_3dset_sort_zposLineCollectionline_collection_2d_to_3dPatchCollectionpatch_collection_2d_to_3dr   rt  r]  r   _segments3drr  r$  _vecPatch3DCollectionrJ   r%  )re   rl  re  r  autolimr   r\  zvalszsortval
collectionrl   s             rm   r  Axes3D.add_collection3d  s|   < ==?b!%*ZZBFF5M 	 9,,,**3D6@Bh'#Y%...**3D6@Bh'#Y%///++CT7ACh'#u5566##RXXcoo%>%H%H%J 7-57C!7!788##SXXcr]FXFC!8!899
 W+C0
ro   )	rc  rd  re  r  rG  ro  	facecolorr  rH  )replace_namesc                X  > U R                  5       nUn[        R                  " XU5      u  pn[        R                  R                  U5      n[        R                  " XX5XjR                  SS5      5      u  pp5pmU
R                  S5      b  XS'   [        R                  " X5      (       a  UR                  5       n[        TU ],  " X/U	Q7XVS.U
D6n[        R                  " XUUUS9  U R                  S:  a!  UR                  S:  a  U R!                  S5        U R#                  XX;5        U$ )a  
Create a scatter plot.

Parameters
----------
xs, ys : array-like
    The data positions.
zs : float or array-like, default: 0
    The z-positions. Either an array of the same length as *xs* and
    *ys* or a single value to place all points in the same plane.
zdir : {'x', 'y', 'z', '-x', '-y', '-z'}, default: 'z'
    The axis direction for the *zs*. This is useful when plotting 2D
    data on a 3D Axes. The data must be passed as *xs*, *ys*. Setting
    *zdir* to 'y' then plots the data to the x-z-plane.

    See also :doc:`/gallery/mplot3d/2dcollections3d`.

s : float or array-like, default: 20
    The marker size in points**2. Either an array of the same length
    as *xs* and *ys* or a single value to make all markers the same
    size.
c : :mpltype:`color`, sequence, or sequence of colors, optional
    The marker color. Possible values:

    - A single color format string.
    - A sequence of colors of length n.
    - A sequence of n numbers to be mapped to colors using *cmap* and
      *norm*.
    - A 2D array in which the rows are RGB or RGBA.

    For more details see the *c* argument of `~.axes.Axes.scatter`.
depthshade : bool, default: True
    Whether to shade the scatter markers to give the appearance of
    depth. Each call to ``scatter()`` will perform its depthshading
    independently.
axlim_clip : bool, default: False
    Whether to hide the scatter points outside the axes view limits.

    .. versionadded:: 3.10
data : indexable object, optional
    DATA_PARAMETER_PLACEHOLDER
**kwargs
    All other keyword arguments are passed on to `~.axes.Axes.scatter`.

Returns
-------
paths : `~matplotlib.collections.PathCollection`
rH  N)r  ro  )re  r  
depthshader   皙?r   )r  r   r
  r   marV  delete_masked_pointsrN  may_share_memorycopyrJ   scatterr   r  r0  r  r6  r]  )re   rc  rd  re  r  r  ro  r  r   rh   ri   r\  zs_origrH  patchesrl   s                  rm   r  Axes3D.scatterH  s   n ==?00<
EEKKN"'"<"<B1jj$7#q ::g*#7O w++B'/"DTDADVD''T3=3=	? ==4BGGaKT"BB1ro   c                2  > U R                  5       n[        TU ]  " X/UQ70 UD6n	[        R                  " U[        U5      SS9n/ n
/ n[        X5       Hq  u  p[        R                  " U5      nXR                  5       -  n
X/[        U5      -  -  n[        R                  " XXE5        SU;   d  M]  UR                  US   5        Ms     [        U
5      S:  a  [        U
6 u  nnO/ / nn[        R                  " UUX5      u  nnnU R                  UUX5        U	$ )a  
Add 2D bar(s).

Parameters
----------
left : 1D array-like
    The x coordinates of the left sides of the bars.
height : 1D array-like
    The height of the bars.
zs : float or 1D array-like, default: 0
    Z coordinate of bars; if a single value is specified, it will be
    used for all bars.
zdir : {'x', 'y', 'z'}, default: 'z'
    When plotting 2D data, the direction to use as z ('x', 'y' or 'z').
axlim_clip : bool, default: False
    Whether to hide bars with points outside the axes view limits.

    .. versionadded:: 3.10
data : indexable object, optional
    DATA_PARAMETER_PLACEHOLDER
**kwargs
    Other keyword arguments are forwarded to
    `matplotlib.axes.Axes.bar`.

Returns
-------
mpl_toolkits.mplot3d.art3d.Patch3DCollection
T)subokalphar   )r  rJ   barr   broadcast_tor>  rs  r   _get_patch_vertsr  patch_2d_to_3d	set_alphar  r]  )re   r  r   re  r  r   rh   ri   r\  r  r  verts_zsr  r   vsrc  rd  rl   s                    rm   r  
Axes3D.bar  s   > ==?'+d<T<V<__RT$7$DA''*BYY[ Ec"g%H  t8& F7O, % u:> %[FBB ,,RXDBBH7ro   c          	          U R                  5       n[        R                  " [        R                  " U5      X#XEU5      u  pp4pV[        R                  " U5      n[        R
                  " X-   5      n[        R                  " U5      n[        R
                  " X%-   5      n[        R                  " U5      n[        R
                  " X6-   5      n[        R                  " / SQ5      n[        R                  " UR                  UR                  -   5      nSX4SX%4SX644 Ha  u  nnnUS[        R                  [        R                  4   nUS[        R                  [        R                  4   nUUUSU4   -  -   USU4'   Mc     UR                  SUR                  SS -   5      n/ nUc  U R                  R                  5       /n[        [        R                  " U5      5      n[!        U5      [!        U5      :X  a  U H  nUR#                  U/S-  5        M     O+Un[!        U5      [!        U5      :  a  US[!        U5      -  -  n[$        R&                  " U/UQ7UUU	U
US	.UD6nU R)                  U5        U R+                  UU4UU4UU4U5        U$ )
a  
Generate a 3D barplot.

This method creates three-dimensional barplot where the width,
depth, height, and color of the bars can all be uniquely set.

Parameters
----------
x, y, z : array-like
    The coordinates of the anchor point of the bars.

dx, dy, dz : float or array-like
    The width, depth, and height of the bars, respectively.

color : sequence of colors, optional
    The color of the bars can be specified globally or
    individually. This parameter can be:

    - A single color, to color all bars the same color.
    - An array of colors of length N bars, to color each bar
      independently.
    - An array of colors of length 6, to color the faces of the
      bars similarly.
    - An array of colors of length 6 * N bars, to color each face
      independently.

    When coloring the faces of the boxes specifically, this is
    the order of the coloring:

    1. -Z (bottom of box)
    2. +Z (top of box)
    3. -Y
    4. +Y
    5. -X
    6. +X

zsort : {'average', 'min', 'max'}, default: 'average'
    The z-axis sorting scheme passed onto `~.art3d.Poly3DCollection`

shade : bool, default: True
    When true, this shades the dark sides of the bars (relative
    to the plot's source of light).

lightsource : `~matplotlib.colors.LightSource`, optional
    The lightsource to use when *shade* is True.

axlim_clip : bool, default: False
    Whether to hide the bars with points outside the axes view limits.

    .. versionadded:: 3.10

data : indexable object, optional
    DATA_PARAMETER_PLACEHOLDER

**kwargs
    Any additional keyword arguments are passed onto
    `~.art3d.Poly3DCollection`.

Returns
-------
collection : `~.art3d.Poly3DCollection`
    A collection of three-dimensional polygons representing the bars.
))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  r  r  r  )r  r  r  r  )r  r  r  r  )r  r  r  r  r   r   r   .)r  N   )zsortr  r  r<  r   )r  r   rK  r  r  r   r   r#  rS  newaxisreshaper  r  r  r  r  r>  r  r   r$  r%  r]  )re   r   r   r   rl  rm  rn  rH  r
  r  r<  r   rh   ri   r\  r   r   r   r   r   r   cuboidr)  r   r  dpr  ro  rl  s                                rm   bar3dAxes3D.bar3d  sQ   H ==? 11MM!aBB0aRvvayvvaf~vvayvvaf~vvayvvaf~
  +
 +\ 6<</0 QaZ!Q<HAq"#rzz2::-.ACRZZ/0BVCF^ 33E#q&M = eekk!"o56
=//>>@AEW**512u:Q!!1#'*  J:Q'q3q6z*
$$U 6 '+6+00:+01<0:6 /56 	C T4L4,thO
ro   c                    > [         TU ]  " U4X#S.UD6nU R                  R                  5       u  pgU R                  R	                  SU-  5        U$ )N)r  r~  gq=
ףp?)rJ   	set_titletitler   set_y)	re   r  r  r~  ri   retr   r   rl   s	           rm   r  Axes3D.set_title  sK    gLLVL((*

"
ro   g333333?tail)lengtharrow_length_ratiopivot	normalizer   c          
         S nU R                  5       n[        R                  " XX4XVSS9n[        S U 5       5      (       a*  [        R
                  " / 40 UD6nU R                  U5        U$ [        R                  " SU/[        S9nUU-  n[        R                  " / SQU	S9  U	S	:X  a  UU-  nOU	S
:X  a  UUS-  -  n[        R                  " USS 5      n[        R                  " USS 5      R                  [        5      nU
(       a:  [        R                  R                  USS9nSUUS:H  '   UUR!                  S5      -  n[#        U5      S:  a  U[        R$                  R'                  UU5      -
  R)                  SS5      nU" U5      nUSS2SS24   [        R$                  R'                  UU5      -
  nUR!                  [#        U5      SS45      nUR)                  SS5      n/ UQUSSS2   QUSSS2   QnO/ n[        R
                  " U4SU0UD6nU R                  U5        U R+                  USS2S4   USS2S4   USS2S4   U5        U$ )a  
Plot a 3D field of arrows.

The arguments can be array-like or scalars, so long as they can be
broadcast together. The arguments can also be masked arrays. If an
element in any of argument is masked, then that corresponding quiver
element will not be plotted.

Parameters
----------
X, Y, Z : array-like
    The x, y and z coordinates of the arrow locations (default is
    tail of arrow; see *pivot* kwarg).

U, V, W : array-like
    The x, y and z components of the arrow vectors.

length : float, default: 1
    The length of each quiver.

arrow_length_ratio : float, default: 0.3
    The ratio of the arrow head with respect to the quiver.

pivot : {'tail', 'middle', 'tip'}, default: 'tail'
    The part of the arrow that is at the grid point; the arrow
    rotates about this point, hence the name *pivot*.

normalize : bool, default: False
    Whether all arrows are normalized to have the same length, or keep
    the lengths defined by *u*, *v*, and *w*.

axlim_clip : bool, default: False
    Whether to hide arrows with points outside the axes view limits.

    .. versionadded:: 3.10

data : indexable object, optional
    DATA_PARAMETER_PLACEHOLDER

**kwargs
    Any additional keyword arguments are delegated to
    :class:`.Line3DCollection`
c           
      :   U S S 2S4   nU S S 2S4   n[         R                  R                  U S S 2S S24   SS9n[         R                  " X#US:g  [         R                  " U5      S9n[         R                  " U* X3S:g  [         R
                  " U5      S9n[        R                  " S5      n[        R                  " U5      n[        R                  " U5      nXX-  n	XH-  n
XE-  SU-
  -  n[         R                  " XtS-  SU-
  -  -   X/XUS-  SU-
  -  -   U
* /U	* U
[         R                  " XG5      //5      nUR                  5       nU/ SQ/ SQ4==   S	-  ss'   [         R                  " S
X5      n[         R                  " S
X5      n[         R                  " X/SS9$ )Nr   r   r   r   )r  r     )r   r   r   r   )r   r   r   r   r  zij...,...j->...i)r   r   r   divide
zeros_like	ones_likemathradiansr  r  r   	full_liker  einsumrO  )UVWr   r   r   x_py_pranglero  r  r13r32r12RposRneg	Rpos_vecs	Rneg_vecss                   rm   calc_arrows"Axes3D.quiver.<locals>.calc_arrows  sy   AqD	AAqD	A99>>#a!e*1>5D))A419"--:JKC))QBQYBLLOLC\\"%F A A'C'C)q1u%C88axAE**C5C1HQ//#6$R\\#1245D
 99;D|+,2,		"4d@I		"4d@I88Y2;;ro   T)compressc              3   >   #    U  H  n[        U5      S :H  v   M     g7f)r   N)r>  )r  r  s     rm   r   Axes3D.quiver.<locals>.<genexpr>  s     /Jqs1v{Js   r,   r   )r  middletip)r  r  r6  r   Nr   r   r   r   )r  r   r  r   )r  r   r
  anyr   rt  r%  r   r   r   r   r   rU  astyper   r   r  r>  multiplyouterswapaxesr]  )re   rY  rZ  r[  Ur  Wr  r  r  r  r   ri   r1  r\  
input_argsr  shaft_dtarrow_dtXYZr&  r   shafts	head_dirsheadsr  s                             rm   quiverAxes3D.quiver  s@   `	<8 ==?00qQ:>@
 /J///**288E&L88RL6004EBF?Hh
"Hooj!n-oojn-44U; 99>>#A>.DDOW--Cs8a<BKK--h<<FFq!LF#C(I1bqb5MBKK$5$5h	$JJEMM3x="a"89ENN1a(E8f8uSqSz8E!$Q$K8EE&&uNNvNE"C1Is1a4y#ad)XFro   r  rG  r  r<  r   c          
        ^2^3 [        U5      S:  a  S nOS nU" U0 UD6u  n	m3nT3R                  S:w  a  [        S5      e[        R                  " T3R
                  [        R                  S9n
[        U
S-   5      m2U	c  [        R                  " T25      u  pnOU24S jU	 5       u  pnU34S	 jnUc  U R                  R                  5       nU" US
5      nU" US5      nU R                  XU5        [        R                  " / SQ/ SQ/ SQ/ SQ/[        R                  S9n[        [        5      nS nU" S5       GH  nUR                  R                  U
5      u  nnn[        R                   " U5      n[        R                   " U5      n[        R                   " U5      nUR                  UR                  5      nUSSS2   nU GHc  nU GHX  nUR                  UUS/5      n[        U5      nT3U   (       a  UU   R#                  UU-   5        [$        R&                  " U5       H  u  nn UR                  UUU/5      n!UR                  UUU /5      n"[        U!5      n#[        U"5      n$T3U#   (       a#  T3U$   (       d  UU#   R#                  U"U-   5        Mq  T3U#   (       a  M}  T3U$   (       d  M  UU$   R#                  U"U-   5        M     UR                  UUUS-
  /5      n%UR                  UUU/5      n&[        U%5      n'T3U'   (       d  GMA  UU'   R#                  U&U-   5        GM[     GMf     GM     0 n(UR)                  5        H  u  n)n*U	c  U*n+Oz/ n+U* Hr  n,U,SS2S4   U,SS2S4   U,SS2S4   4n-[        R*                  " U,R
                  5      n.UU-   U.SS2S4'   UU-   U.SS2S4'   UU-   U.SS2S4'   U+R#                  U.5        Mt     UU)   n/UU)   n0[,        R.                  " U+4U/U0X4US.UD6n1U R1                  U15        U1U(U)'   M     U($ )aw	  
ax.voxels([x, y, z,] /, filled, facecolors=None, edgecolors=None, **kwargs)

Plot a set of filled voxels

All voxels are plotted as 1x1x1 cubes on the axis, with
``filled[0, 0, 0]`` placed with its lower corner at the origin.
Occluded faces are not plotted.

Parameters
----------
filled : 3D np.array of bool
    A 3D array of values, with truthy values indicating which voxels
    to fill

x, y, z : 3D np.array, optional
    The coordinates of the corners of the voxels. This should broadcast
    to a shape one larger in every dimension than the shape of
    *filled*.  These can be used to plot non-cubic voxels.

    If not specified, defaults to increasing integers along each axis,
    like those returned by :func:`~numpy.indices`.
    As indicated by the ``/`` in the function signature, these
    arguments can only be passed positionally.

facecolors, edgecolors : array-like, optional
    The color to draw the faces and edges of the voxels. Can only be
    passed as keyword arguments.
    These parameters can be:

    - A single color value, to color all voxels the same color. This
      can be either a string, or a 1D RGB/RGBA array
    - ``None``, the default, to use a single color for the faces, and
      the style default for the edges.
    - A 3D `~numpy.ndarray` of color names, with each item the color
      for the corresponding voxel. The size must match the voxels.
    - A 4D `~numpy.ndarray` of RGB/RGBA data, with the components
      along the last axis.

shade : bool, default: True
    Whether to shade the facecolors.

lightsource : `~matplotlib.colors.LightSource`, optional
    The lightsource to use when *shade* is True.

axlim_clip : bool, default: False
    Whether to hide voxels with points outside the axes view limits.

    .. versionadded:: 3.10

**kwargs
    Additional keyword arguments to pass onto
    `~mpl_toolkits.mplot3d.art3d.Poly3DCollection`.

Returns
-------
faces : dict
    A dictionary indexed by coordinate, where ``faces[i, j, k]`` is a
    `.Poly3DCollection` of the faces drawn for the voxel
    ``filled[i, j, k]``. If no faces were drawn for a given voxel,
    either because it was not asked to be drawn, or it is fully
    occluded, then ``(i, j, k) not in faces``.

Examples
--------
.. plot:: gallery/mplot3d/voxels.py
.. plot:: gallery/mplot3d/voxels_rgb.py
.. plot:: gallery/mplot3d/voxels_torus.py
.. plot:: gallery/mplot3d/voxels_numpy_logo.py
r   c                     XU4X44$ r   r   )
_Axes3D__x
_Axes3D__y
_Axes3D__zfilledri   s        rm   voxelsAxes3D.voxels.<locals>.voxelsX  s    #66ro   c                 
    S X4$ r   r   )rN  ri   s     rm   rO  rP  [  s    V++ro   z%Argument filled must be 3-dimensionalr   r   Nc              3   R   >#    U  H  n[         R                  " UT5      v   M     g 7fr   )r   r  )r  ro  coord_shapes     rm   r   Axes3D.voxels.<locals>.<genexpr>j  s     D1rq+66s   $'c                 j  > [         R                  " U 5      S;   a8  [         R                  " U TR                  [         R                  " U 5      -   5      $ [         R                  " U 5      S;   a8  [         R                  " U 5      S S TR                  :w  a  [	        SU S35      eU $ [	        SU S35      e)N)r   r   )r   r   r   zWhen multidimensional, z must match the shape of filledzInvalid z	 argument)r   rI  r  rS  r   )rH  r  rN  s     rm   _broadcast_color_arg+Axes3D.voxels.<locals>._broadcast_color_argl  s    wwu~'ufllRXXe_.LMM6)88E?2A&&,,6$1$ 8$ $% %  8D6!;<<ro   r  rG  r  r  r  r  c              3      #    [         R                  " U [         R                  S9n[        U 5       H  nUv   [         R                  " USSS9nM     g7f)z%Generate cyclic permutation matrices.r   r   r   r   N)r   r  intprx  r$   )nmatr   s      rm   permutation_matrices+Axes3D.voxels.<locals>.permutation_matrices  s>     &&"''*C1X	ggc11- s   AAr  r   r   rH  )r>  rI  r   r   r   rS  rY  r  indicesr  r  r]  r   r  r  r  arangerv  rQ  rR  itemsr#  r   r$  r  )4re   r  rG  r  r<  r   rh   ri   rO  xyzr  r   r   r   rV  squarevoxel_facesr\  permutepcqcrcpindsqindsrindssquare_rot_possquare_rot_negr  r  r  i0r1r  r  r  i1i2pkpk2ikpolygonscoord
faces_indsfaces	face_indsindfacer  	edgecolorr6  rS  rN  s4                                                     @@rm   rO  Axes3D.voxels
  s   X t9>7, %d5f5VV ;;!DEExxBGG4 D1Ho;jj-GA!DDGA!	= 33BBDJ)*lC
 **lC
 	A!$ 	

  "$'	. ,A.G t,JBBIIbMEIIbMEIIbME#ZZ		2N+DbD1N A !aAY/BrBbz#B..rN/BC #,"4"4U";B$[[!Q4$[[!Q4"2Y"2Y!":fRj'O2223FG!'r

'O2223FG #< !aBqD\2B!++q!Rj1CrBbzz#B..s^/CD;   /Z !,!2!2!4E:{"!+I#AqD/9QT?IadOKC88IOO4D!"3DAJ!"3DAJ!"3DAJLL& ", #5)I"5)I))"+	 D !!$'"HUO/ "52 ro   )r   r   r   xerryerrzerrc                   ^M^N U R                  5       n[        R                  " U[        R                  5      nUR                  5        VVs0 s H  u  nnUc  M  UU_M     nnnUR                  SS5        U R                  SU4SU4SU4/USS9  [        R                  " U5      (       a  UOU/n[        R                  " U5      (       a  UOU/n[        R                  " U5      (       a  UOU/n[        U5      [        U5      s=:X  a  [        U5      :X  d  O  [        S	5      eU R                  X5      mMUR                  S
S5      nSUS
'   U R                  R                  XS:X  a  X4OXU4USS9u  u  nn[         R"                  " UUUS9  U(       a  UR%                  US   S-
  5        OUR%                  US   S-   5        UR'                  5       S:w  a  U R)                  U5        OSnUR                  S5        SU;  a  SUS'   U
c  US   n
S H  nUR                  US5        M     0 UESU
0EnU(       a  UUS'   OSU;   a  US   US'   S H  nUU;   d  M  UU   UU'   M     0 UESS0EnUc  [*        R,                  S   nUS:  a  SU-  US'   Ub  UUS'   U
US'   S nUM4S jn / / / n#n"n!/ n$S S S!S".n%SS#SS$.mNUR/                  S[*        R,                  S%   5      S-  n&U&U R1                  SS&9R2                  S'-  -  n&U R4                  R7                  5       R9                  S(U&U&4/5      n&[        R:                  " [        R<                  " U&SS)95      n&[        R>                  " U SSSS*9   [        R@                  RC                  U RE                  5       5      n'SSS5        [        RF                  " W'U&SSS/5      S#   n&U&S+-  n&0 UEU&S#S,.En(U(R                  SS5        [I        / S$QXU/XeU/UUU/UUU/5       GH  u  n)n*n+n,n-[         RJ                  " U)5      n.TNU)   n/U+c  M*  [        R                  " U+5      (       d  U+/[        U*5      -  n+[        RL                  " U+5      n+[        RN                  " U,[        U*5      5      RQ                  [R        5      n,[        RN                  " U-[        U*5      5      RQ                  [R        5      n-[U        XU/5       V0V1s/ s H  u  n0n1U " U+U.U0   -  U1U,U-5      PM     n2n0n1U2u  u  n3n4u  n5n6u  n7n8U,U--  ) n9U9RW                  5       (       a  US:  a  U" U3U5U7/U9TM-  5      n:U" U4U6U8/U9TM-  5      n;[         RX                  " U:SU%U/   US-.UD6n<[         RX                  " U;SU%U/   US-.UD6n=U R)                  U<5        U R)                  U=5        U"R[                  U<5        U"R[                  U=5        U,RW                  5       (       a+  U" U4U6U8/U,TM-  5      u  n>n?n@U R\                  " U>U?U@/U.Q70 U(D6  U-RW                  5       (       a,  U" U3U5U7/U-TM-  5      u  nAnBnCU R\                  " UAUBUC/U.* Q70 U(D6  [         R^                  " [        R`                  " U25      Rb                  4S.U0UD6nDU Re                  UD5        U!R[                  UD5        U$R[                  U25        GM     [        R`                  " U$5      n$UN4S/ jnEUE" U$S5      u  nFnGUE" U$S5      u  nHnIUE" U$S5      u  nJnKU Rg                  UFUG4UHUI4UJUK4U5        [h        Rj                  " U[m        U"5      [m        U!5      4USL=(       d    USLUSLUS09nLU Rn                  R[                  UL5        U!U"U#4$ s  snnf ! , (       d  f       GN= fs  sn1n0f )1a  
Plot lines and/or markers with errorbars around them.

*x*/*y*/*z* define the data locations, and *xerr*/*yerr*/*zerr* define
the errorbar sizes. By default, this draws the data markers/lines as
well the errorbars. Use fmt='none' to draw errorbars only.

Parameters
----------
x, y, z : float or array-like
    The data positions.

xerr, yerr, zerr : float or array-like, shape (N,) or (2, N), optional
    The errorbar sizes:

    - scalar: Symmetric +/- values for all data points.
    - shape(N,): Symmetric +/-values for each data point.
    - shape(2, N): Separate - and + values for each bar. First row
      contains the lower errors, the second row contains the upper
      errors.
    - *None*: No errorbar.

    Note that all error arrays should have *positive* values.

fmt : str, default: ''
    The format for the data points / data lines. See `.plot` for
    details.

    Use 'none' (case-insensitive) to plot errorbars without any data
    markers.

ecolor : :mpltype:`color`, default: None
    The color of the errorbar lines.  If None, use the color of the
    line connecting the markers.

elinewidth : float, default: None
    The linewidth of the errorbar lines. If None, the linewidth of
    the current style is used.

capsize : float, default: :rc:`errorbar.capsize`
    The length of the error bar caps in points.

capthick : float, default: None
    An alias to the keyword argument *markeredgewidth* (a.k.a. *mew*).
    This setting is a more sensible name for the property that
    controls the thickness of the error bar cap in points. For
    backwards compatibility, if *mew* or *markeredgewidth* are given,
    then they will over-ride *capthick*. This may change in future
    releases.

barsabove : bool, default: False
    If True, will plot the errorbars above the plot
    symbols. Default is below.

xlolims, ylolims, zlolims : bool, default: False
    These arguments can be used to indicate that a value gives only
    lower limits. In that case a caret symbol is used to indicate
    this. *lims*-arguments may be scalars, or array-likes of the same
    length as the errors. To use limits with inverted axes,
    `~.set_xlim`, `~.set_ylim`, or `~.set_zlim` must be
    called before `errorbar`. Note the tricky parameter names: setting
    e.g. *ylolims* to True means that the y-value is a *lower* limit of
    the True value, so, only an *upward*-pointing arrow will be drawn!

xuplims, yuplims, zuplims : bool, default: False
    Same as above, but for controlling the upper limits.

errorevery : int or (int, int), default: 1
    draws error bars on a subset of the data. *errorevery* =N draws
    error bars on the points (x[::N], y[::N], z[::N]).
    *errorevery* =(start, N) draws error bars on the points
    (x[start::N], y[start::N], z[start::N]). e.g. *errorevery* =(6, 3)
    adds error bars to the data at (x[6], x[9], x[12], x[15], ...).
    Used to avoid overlapping error bars when two series share x-axis
    values.

axlim_clip : bool, default: False
    Whether to hide error bars that are outside the axes limits.

    .. versionadded:: 3.10

Returns
-------
errlines : list
    List of `~mpl_toolkits.mplot3d.art3d.Line3DCollection` instances
    each containing an errorbar line.
caplines : list
    List of `~mpl_toolkits.mplot3d.art3d.Line3D` instances each
    containing a capline object.
limmarks : list
    List of `~mpl_toolkits.mplot3d.art3d.Line3D` instances each
    containing a marker with an upper or lower limit.

Other Parameters
----------------
data : indexable object, optional
    DATA_PARAMETER_PLACEHOLDER

**kwargs
    All other keyword arguments for styling errorbar lines are passed
    `~mpl_toolkits.mplot3d.art3d.Line3DCollection`.

Examples
--------
.. plot:: gallery/mplot3d/errorbar3d.py
Nr  r   r   r   r   F)convertz)'x', 'y', and 'z' must have the same sizer  
_nolegend_rM  T)return_kwargs)re  r   g?nonerH  C0)marker
markersizemarkerfacecolormarkeredgewidthmarkeredgecolor	markevery	linestyle	fillstyle	drawstyledash_capstyledash_joinstylesolid_capstylesolid_joinstyle	linewidth)r`   r  r  
rasterizedr  Nonezerrorbar.capsizer   r   r  r  c                 ^    U  Vs/ s H  n/ [         R                  " X!5      QPM     sn$ s  snf r   )rQ  r3  )arraysr  r   s      rm   _apply_mask$Axes3D.errorbar.<locals>._apply_mask  s/     EKKF56i((56FKKKs   "*c                    > [        U R                  5      S:X  a  U u  pEOX pT[        R                  " UT) -  XU-
  5      n[        R                  " UT) -  XU-   5      nXg4$ )Nr   )r>  rS  r   r  )	errdatalomaskhimasklow_errhigh_errlowshighs	everymasks	           rm   _extract_errs&Axes3D.errorbar.<locals>._extract_errs  s`    399~"$'!$'88FiZ/g~FDHHVyj0$xHE;ro   |_r   r   r   zlines.markersizer3   H   r8   r   )r"   r#   r$   gV&,t=?)r  r  )lsr  r   r   c           	         > [         R                  " U S S 2TU   S S 2S S 24   5      [         R                  " U S S 2TU   S S 2S S 24   5      4$ r   )r   r  r  )err_arrcoord_labeli_xyzs     rm   _digout_minmax'Axes3D.errorbar.<locals>._digout_minmax  sM    IIga{);Q&ABCIIga{);Q&ABCE Ero   )has_xerrhas_yerrr  )8r  r   normalize_kwargsrc  rd  r`  
setdefault_process_unit_infor   r}  r>  r   _errorevery_to_maskrH   r[  
_plot_argsr   r  
set_zorderr  add_liner  r  rN  rT   dpi	transAxesr_   r`   r   r  _setattr_cmr   r  r  r  rs  get_dir_vectorr  r  r9  re  r   r8  Line3Drv  rF  rt  r   r  r%  r]  
mcontainerErrorbarContainerr  
containers)Ore   r   r   r   r  r~  r}  fmt	barsabove
erroreveryecolor
elinewidthcapsizecapthickxlolimsxuplimsylolimsyuplimszlolimszuplimsr   ri   r\  r  r  r  	data_line
base_styler  eb_lines_styleeb_cap_styler  r  errlinescaplineslimmarks	coorderrs	capmarker
quiversizerO   eb_quiver_styler  r  r  lolimsuplims
dir_vectori_zdirr   ru  coorderrr  xhr  yhr  zhnolimslo_caps_xyzhi_caps_xyzcap_locap_hixh0yh0zh0xl0yl0zl0errliner  r   r   r   r   r   r   errorbar_containerr  r  sO                                                                                @@rm   errorbarAxes3D.errorbar  s   b ==?''>#)<<>C>41aQ$!Q$>C(A&#qC8c1X >(- 	  	/
 QAaSQAaSQAaS1vQ)3q6)HII,,Q;	

7D)&w $(??#=#=2I1&A#;d $> $T JI!
C   !1B!67  !1B!67 99;& MM)$INN7#*$"&Jw>(FKC NN3%	K 9J88*4N;'F"*0*=N;'ACf}&,Sks# B
 ;*:k6:?ll#56GQ;)+gL&.6L*+ &W	L

	 (*2rH( 	 ,	aa( "%%l&)ll3E&FHKLM
doo4o044r99
^^,,.88Z,:. /
WWRWWZa89
 t!!!<99==1D = VVD:q!Q"78;
 	((
J\ J%/qJL$/ 03!T,>'7+gw-H0J+D$VV --d3J4[F{;;s##ec$i'--$C __VSY7>>tDF__VSY7>>tDF !*1) 46 4HAu cJqM15&&I 4  6 ,4(HRhr2R 'Fzz||!)2r2,8JK)2r2,8JK {r-6v->1;6 )56 {r-6v->1;6 )56 f%f%''zz|| +RRL&9:L MS#CcJJJ/Jzz|| +RRL&9:L MS#CcKZKK?K,,RXXh-?-A-A ?8B?/=?G (OOG$X&y0J| HHY'		E $Is3
d#Is3
d#Is3
dT4L4,thO (99hx9$&:$d*:$&	
 	128++m Dn =<H6s   
]/]/..]5^5
^call_axes_locatorbbox_extra_artistsfor_layout_onlyc                Z  > [         T	U ]  UUUUS9nU/nU R                  (       ah  U R                  R	                  5        HJ  nUR                  5       (       d  M  [        R                  " Xq5      nU(       d  M9  UR                  U5        ML     [        R                  R                  U5      $ )Nr  )rJ   get_tightbboxrr   r  r  r  martist_get_tightbbox_for_layout_onlyrv  r   r   union)
re   r  r  r  r  r  batchr   axis_bbrl   s
            rm   r  Axes3D.get_tightbbox.  s    g#H6G7I4C $ E >>--/##%%%DD(GwW- 0 %%e,,ro   zC0-C0ozC3-)linefmt	markerfmtbasefmtr  r  orientationr   c          	      x   SSK Jn  U R                  5       n[        R                  " / SQU	S9  [
        R                  " U5      [
        R                  " U5      4n[
        R                  " U5      [
        R                  " U5      4n[
        R                  " U5      [
        R                  " U5      4nU	S:X  a3  X.nnX?nn[        XU5       VVVs/ s H  u  nnnUUU4UUU4/PM     nnnnOkU	S:X  a3  XnnX?nn[        XU5       VVVs/ s H  u  nnnUUU4UUU4/PM     nnnnO2XnnX.nn[        XU5       VVVs/ s H  u  nnnUUU4UUU4/PM     nnnn[        U5      u  nnnUc  [        R                  S   nU R                  UUXgU	SS	9u  n[        R                  " UUUSU
S
9nU R                  U5        U R                  XX5SS9u  nU" UUU4US9nU R!                  U5        [        R"                  " UUXw/U	5      u  nn n!U R%                  / UQUQ/ U QUQ/ U!QUQU5        U$ s  snnnf s  snnnf s  snnnf )a  
Create a 3D stem plot.

A stem plot draws lines perpendicular to a baseline, and places markers
at the heads. By default, the baseline is defined by *x* and *y*, and
stems are drawn vertically from *bottom* to *z*.

Parameters
----------
x, y, z : array-like
    The positions of the heads of the stems. The stems are drawn along
    the *orientation*-direction from the baseline at *bottom* (in the
    *orientation*-coordinate) to the heads. By default, the *x* and *y*
    positions are used for the baseline and *z* for the head position,
    but this can be changed by *orientation*.

linefmt : str, default: 'C0-'
    A string defining the properties of the vertical lines. Usually,
    this will be a color or a color and a linestyle:

    =========  =============
    Character  Line Style
    =========  =============
    ``'-'``    solid line
    ``'--'``   dashed line
    ``'-.'``   dash-dot line
    ``':'``    dotted line
    =========  =============

    Note: While it is technically possible to specify valid formats
    other than color or color and linestyle (e.g. 'rx' or '-.'), this
    is beyond the intention of the method and will most likely not
    result in a reasonable plot.

markerfmt : str, default: 'C0o'
    A string defining the properties of the markers at the stem heads.

basefmt : str, default: 'C3-'
    A format string defining the properties of the baseline.

bottom : float, default: 0
    The position of the baseline, in *orientation*-coordinates.

label : str, optional
    The label to use for the stems in legends.

orientation : {'x', 'y', 'z'}, default: 'z'
    The direction along which stems are drawn.

axlim_clip : bool, default: False
    Whether to hide stems that are outside the axes limits.

    .. versionadded:: 3.10

data : indexable object, optional
    DATA_PARAMETER_PLACEHOLDER

Returns
-------
`.StemContainer`
    The container may be treated like a tuple
    (*markerline*, *stemlines*, *baseline*)

Examples
--------
.. plot:: gallery/mplot3d/stem3d_demo.py
r   )StemContainerr   )r   r   r   zlines.linestyler  )re  r  r  )
linestylesr  r  r   )r  )matplotlib.containerr  r  r   r   r   r  r   rs  r
   r  r  r  r   rt  r%  add_containerr  r]  )"re   r   r   r   r  r  r  r  r  r   r   r  r\  r   r   r   basexbasexlimbaseybaseylimthisxthisythiszr  r  
linemarker	linecolorbaseline	stemlines
markerlinestem_containerjxjyjzs"                                     rm   stemAxes3D.stem>  s   N 	7==??Dq	266!9%q	266!9%q	266!9% #8E8E03A!>0<,u ue,ueU.CD0<  >EC8E8E03A!>0<,u fe,ueU.CD0<  >E  8E8E03A!>0<,u eV,ueU.CD0<  > ,@+H(	:y%67I IIeUG#.l  D	**i	!#	 	I&iia,iG
&
Ix'H-24>*&&xF;K'24
BLbL4L,B,,"thOG>
>
>s   H'H.:H5)*rN   rF   r   rr   r   r   r  r  r  r	  rb   ra   r  rG   rC   r-  r.  r`  rP   r  r  r  r0  r
  r#   r  r*   r"   rR   r9   r:   r;   rO   r$   rs   r   r@   r>   r   rz   rA   r?   r   )NNF)TrG  N)NN)NTTT)NNN)NNNr   F)F)r   r   r   )inNFF)T)rG  )r  )Fr  r   NF)r   N)r   NF)r   r   T)r   r      NT)r   r   )NaverageTN)Ncenter)NNNrM  Fr   NNNNFFFFFFF)__name__
__module____qualname____firstlineno____doc__r  r  r   Grouperr   rD   rK   rL   rM   r|   r[   r   r   r	   get_zgridlinesget_zticklinesr   r   r   r   r   r  allow_rasterizationr  r'  r+  rN  rM  r1  r6  rD  rP  r]  rQ   r"  r  ri  rj  rk  r  r  r  r  r   r   r   r  r  r  
get_zscale
set_xscale
set_yscale
set_zscalemapformat
get_zticks
set_zticksget_zmajorticklabelsget_zminorticklabelsget_zticklabelsset_zticklabels
zaxis_datetextwrapdedentr  rB   r<   re  r   rT  r   r  rS   r  r  r  r&   r%   r$  rY   rZ   r>  rC  rJ  rS  rN  rO  rq  r_  r   r  rX   r  r  r  r  r  rh  r  r  get_frame_onset_frame_onr%  r  r  r  r  r  text3Dtext2Dr  plot3Dr8  ro  r  r  r  r  r  r  r   r  	contour3Dr  r  r  
contourf3Dr  r  r  	scatter3Dr  r  r  rF  quiver3DrO  r  r  r  stem3D__static_attributes____classcell__)rl   s   @rm   r   r   )   s    D!K"]]_Dc %Df D*cT$D* D*L+
( *'?CN)'?CN1T0l* ./ 'RJ"   9 !9v# -W6IJ,W6IJ , #'$$d "
H!;F $(8<97v2 :>4"525250At4t4A@FPd!4FPPFPd!4FPPFPd!4FPP JJJ000, &g{;J &g/@AJ%g/@AJ%g/@AJAD	 FB>J
*J,>  &g~>J%g{;J/9NO/9NO*74DEO*!!#679O &g{;Jhoo /  	 HKK.Z(: ;@;(;37;	;$9v:*@/&@"/$LH-" #J% E bjj B\6|"9H, 37:?.4`$>LI.&E  LL .<. *'>BN    : FYYF'*u * *X F  fT %B -1tDUEN 5: zx )-4d!%%dL: DH	'6% 6. qs4E( (T I!!#du7 7r/ $5" "H J&)$5 2 2hA$)A AF  %< = :>N N N=N` I99 9 9v /37;ee eN Bf} }~ H'+DEUn $KLEGHLEJFK!	J, MJ,X
-)-u- -  ',uTsux xt Fro   r   c                    [         R                  " SSU 5      =p[         R                  " X5      u  p4[         R                  " US-  US-  -   * S-  5      S[         R                  -  -  n[         R                  " US-
  S-  S-  US-
  S-  S-  -   * S-  5      S[         R                  -  S-  S-  -  nXe-
  nUS-  nUS-  nUS-  nX4U4$ )	z,Return a tuple X, Y, Z with a test data set.g      g      @r   r   g      ?r  r  i  )r   r_  meshgridexpr  )ro  r   r   rY  rZ  Z1Z2r[  s           rm   get_test_datarE    s    IIdC''A;;qDA	!Q$A+"	#q255y	1B
&&QUcMA%!a%3(::;a?
@ruu9s?S "B
A	BA	BA	CA7Nro   c                       \ rS rSrSrS rS rS rS r\	S 5       r
S rS	 rS
 r\rS rS rS r\S 5       r\S 5       rS rSrg)r  i  zV
Quaternions
consisting of scalar, along 1, and vector, with components along i, j, k
c                 F    Xl         [        R                  " U5      U l        g r   )scalarr   r   vector)re   rH  rI  s      rm   rK   _Quaternion.__init__  s    hhv&ro   c                 R    U R                  U R                  * U R                  * 5      $ r   rl   rH  rI  rt   s    rm   __neg___Quaternion.__neg__  s    ~~t{{lT[[L99ro   c                 f   U R                  U R                  UR                  -  [        R                  " U R                  UR                  5      -
  U R                  UR                  -  U R                  UR                  -  -   [        R
                  " U R                  UR                  5      -   5      $ )z
Product of two quaternions
i*i = j*j = k*k = i*j*k = -1
Quaternion multiplication can be expressed concisely
using scalar and vector parts,
see <https://en.wikipedia.org/wiki/Quaternion#Scalar_and_vector_parts>
)rl   rH  r   r  rI  crossre   r  s     rm   __mul___Quaternion.__mul__  sz     ~~KK$rvvdkk5<<'HHKK$t{{5<<'??hht{{ELL123 	3ro   c                 P    U R                  U R                  U R                  * 5      $ )z5The conjugate quaternion -(1/2)*(q+i*q*i+j*q*j+k*q*k)rL  rt   s    rm   	conjugate_Quaternion.conjugate  s    ~~dkkDKK<88ro   c                     U R                   U R                   -  [        R                  " U R                  U R                  5      -   $ )zThe 2-norm, q*q', a scalar)rH  r   r  rI  rt   s    rm   r   _Quaternion.norm  s/     {{4;;&T[[)IIIro   c                     [         R                  " U R                  5      nU R                  U R                  U-  U R
                  U-  5      $ )zScaling such that norm equals 1)r   r  r   rl   rH  rI  re   rZ  s     rm   r  _Quaternion.normalize  s5    GGDII~~dkk!mT[[];;ro   c                 t    U R                   nU R                  U R                  U-  U R                  * U-  5      $ )z.The reciprocal, 1/q = q'/(q*q') = q' / norm(q))r   rl   rH  rI  rZ  s     rm   
reciprocal_Quaternion.reciprocal  s.    II~~dkk!mdkk\!^<<ro   c                 &    XR                  5       -  $ r   )r]  rQ  s     rm   __div___Quaternion.__div__  s    $$&&&ro   c                 L    U R                  SU5      nX-  U -  nUR                  $ )Nr   )rl   rI  )re   r  s     rm   rotate_Quaternion.rotate  s(     NN1a F4Kxxro   c                     U R                   UR                   :H  =(       a#    U R                  UR                  :H  R                  $ r   )rH  rI  rV  rQ  s     rm   __eq___Quaternion.__eq__  s-    u||+R$++2M1R1RRro   c                 r    SR                  [        U R                  5      [        U R                  5      5      $ )Nz_Quaternion({}, {}))r*  reprrH  rI  rt   s    rm   __repr___Quaternion.__repr__  s'    $++D,=tDKK?PQQro   c                    [         R                  " X5      n[         R                  R                  U5      n[         R                  " U[         R
                  " X5      5      nUS-  nUS:X  a  [         R
                  " X5      S:  a  [        R                  " S5        [         R                  " S5      nSU[         R                  " X-  5      '   [         R                  " X5      nU[         R                  R                  U5      -  nU " SU5      nU$ U " S/ SQ5      n U$ U " [         R                  " U5      U[         R                  " U5      -  U-  5      nU$ )z
The quaternion for the shortest rotation from vector r1 to vector r2
i.e., q = sqrt(r2*r1'), normalized.
If r1 and r2 are antiparallel, then the result is ambiguous;
a normal vector will be returned, and a warning will be issued.
r   r   z6Rotation defined by anti-parallel vectors is ambiguousr   r   r  )r   rP  r   r   arctan2r  warningswarnrw  ry  r  r  )clsrn  r  r  r  r  r  s          rm   r  _Quaternion.rotate_from_to  s    HHRYY^^AZZBFF2N+
a7vvb~!VWHHQK&'"))BE"#HHRO		q))1I
  9%  BFF2J"&&*R0Aro   c                    [         R                  " US-  5      [         R                  " US-  5      pT[         R                  " US-  5      [         R                  " US-  5      pv[         R                  " US-  5      [         R                  " US-  5      pXF-  U-  XW-  U	-  -   n
XF-  U	-  XW-  U-  -
  nXG-  U-  XV-  U	-  -   nXG-  U	-  XV-  U-  -
  nU " XX/5      $ )z
Converts the angles to a quaternion
    q = exp((roll/2)*e_x)*exp((elev/2)*e_y)*exp((-azim/2)*e_z)
i.e., the angles are a kind of Tait-Bryan angles, -z,y',x".
The angles should be given in radians, not degrees.
r   )r   r  r  )rp  r"   r#   r$   casacesecrsrqwqxqyqzs                 rm   r  _Quaternion.from_cardan_angles%  s     QQBQQBQQBU2Xb U2Xb U2Xb U2Xb 2B|$$ro   c                    U R                   nU R                  SSS24   u  p#n[        R                  " SU* U-  X#-  -   -  X-  X"-  -   X3-  -
  XD-  -
  5      n[        R                  " [        R
                  " SX-  XB-  -   -  X-  X"-  -   X3-  -   XD-  -   -  SS5      5      n[        R                  " SX-  X4-  -
  -  X-  X"-  -
  X3-  -
  XD-  -   5      nXeU4$ )z
The inverse of `from_cardan_angles()`.
Note that the angles returned are in radians, not degrees.
The angles are not sensitive to the quaternion's norm().
.Nr   r  r   )rH  rI  r   rm  arcsinr  )re   ry  rz  r{  r|  r#   r"   r$   s           rm   r  _Quaternion.as_cardan_angles7  s     [[[[a(
zz!bSVBE\*BE"%K,=be,CDyyBE"%K"%+be2CBE2I!JBPQRSzz!RU25[/25;ru+<RU+BC4ro   )rH  rI  N)r  r  r  r  r   rK   rM  rR  rU  propertyr   r  r]  r`  __truediv__rc  rf  rj  classmethodr  r  r  r>  r   ro   rm   r  r    s    
':39 J J<
=
' KSR  2 % %" ro   r  )r  )7r   collectionsr   rQ  r"  r2  rn  numpyr   
matplotlibr  r   r   r   r   matplotlib.artistr  r  matplotlib.collectionsr   matplotlib.colorsr  r  matplotlib.imageimagera  matplotlib.linesr  rc  matplotlib.patchesr  r   r  	containerr  matplotlib.transforms
transformsr   matplotlib.axesr   matplotlib.axes._baser	   r
   r   matplotlib.tri._triangulationr   rM  r   r   r   interpddefine_aliasesr   rE  r  r   ro   rm   <module>r     s   
 $       @ @ # & # ! ! % ) +   L & 7    J
XJ@ AM>T M>A M>`| v  v ro   