U
    Evf‡ë ã                   @   sX  d Z ddlmZ ddlZddlZddlZddlZddlZddl	Z
ddl	mZmZmZmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl m!Z" ddl#m$Z% ddl&m'Z( ddlm)Z) ddl*m+Z+m,Z, ddl&m-Z- ddl.m/Z/ d	d
l0m1Z1 d	dl0m2Z2 d	dl0m3Z3 ej4e 5dgdgdgdœ¡G dd„ de)ƒƒƒZ6ddd„Z7dS )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)Úaxis3dZxlim3dZylim3dZzlim3d©ÚxlimÚylimÚzlimc                       sx  e Zd ZdZdZdZe ¡ ej	d< e
 d¡Ze
 d¡Ze
 d¡Ze
 d¡Ze
 d¡Zddd	d
ddddddœ‡ fdd„Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZeddƒZeddƒZe
jdd d!d"ed#d$„ ƒƒZe
jdd%d!d"ed&d$„ ƒƒZe
jddd!d"ed'd$„ ƒƒZe
 d¡dd(d)„ƒZ dd*d+„Z!e
 d¡dd,d-„ƒZ"dd.d/„Z#e
 d¡dd0d1„ƒZ$d	d2d3„Z%d
‡ fd5d6„	Z&d7d8„ Z'd9d:œd;d<„Z(dd=d>„Z)e*j+‡ fd?d@„ƒZ,dAdB„ Z-dCdD„ Z.eddEƒZ/eddFƒZ0dGdH„ Z1dddddIœdJdK„Z2ddMdN„Z3ddOdP„Z4ddQdR„Z5dSdT„ Z6e
 7ddU¡ddddVœdWdX„ƒZ8e9jj:Z;e9jj<Z=e8Z>dYdZ„ Z?d[d\„ Z@d]d^„ ZAedd_ƒZBed d`ƒZCed%d`ƒZDedd`ƒZEeFdajGdbdcdgƒ\eC_eD_eE_edddƒZHeddeƒZIeddfƒZJeddgƒZKeddhƒZLeddidjdkidlZMeddmƒZNeNjr"eN jeO Pdn¡7  _dodp„ ZQddqdr„ZRddsdt„ZSdudv„ ZTdwdx„ ZUdd{d|„ZVd}d~„ ZWdd€„ ZXdd‚„ ZYdƒd„„ ZZ‡ fd…d†„Z[d‡dˆ„ Z\d‰dŠ„ Z]d‹dŒ„ Z^ddŽ„ Z_dd„ Z`d‘d’„ Zad“d”„ Zbd•d–„ Zcd—d˜„ Zdddšd›„Zedœd„ ZfdždŸ„ Zgdd d¡„Zhd¢d£„ Zid¤d¥„ Zjd¦d§„ Zkdd¨d©„Zld‡ fdªd«„	Zmd¬d­„ Znedd®ƒZod¯d°„ Zpdd±d²„Zqd‡ fd³d´„	ZrerZsejrZtddµœ‡ fd¶d·„
ZueuZvddddd¸œd¹dº„Zwd»d¼„ Zxdddddd½œd¾d¿„ZyddÁdÂ„ZzddÃdÄ„Z{ddÅdÆ„Z|ddÇdÈ„Z}e~ƒ d4dÀdddÉœ‡ fdÊdË„
ƒZeZ€e~ƒ d4dÀdddÉœ‡ fdÌdÍ„
ƒZdÎdÏ„ Z‚e~ƒ dddÐœ‡ fdÑdÒ„
ƒZƒeƒZ„e~ƒ dddÐœ‡ fdÓdÔ„
ƒZ…d‡ fdÕdÖ„	Z†e~d×dØdÙdÚdÛdÜdÝdÞdßg	dàd‡ fdâdã„	ƒZ‡e‡Zˆe~ƒ d‡ fdädå„	ƒZ‰e~ƒ d dçdè„ƒZŠd!‡ fdêdë„	Z‹e~ƒ d9dìdíd4dîœdïdð„ƒZŒeŒZdddddñœdòdó„ZŽe~dbdcddôdõdögdàd"dødù„ƒZd#d4dúœ‡ fdûdü„Ze~ƒ dýdþdÿd
ddd œdd„ƒZ‘e‘Z’‡  Z“S ($  ÚAxes3Da  
    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`.
    Z3d©ÚxÚyÚzr   z3.6z3.7Né   iÄÿÿÿr   ÚperspT)ÚelevÚazimÚrollÚsharezÚ	proj_typeÚ
box_aspectÚcomputed_zorderÚfocal_lengthc                   sˆ  |dkrddddg}|| _ || _|| _|  ||
¡ |	| _t ¡ | _t ¡ | _t ¡ | _	t ¡ | _
|  | j| j | j¡ || _|dk	rš| jd  | |¡ d| _| dd¡r®tdƒ‚tƒ j||f|žd	|d
œ|—Ž tƒ  ¡  |  ¡  d| _d| _|  ¡  | jjj d| j¡ | jjj d| j¡ | jjj d| j¡ |   ¡  | j! "d¡ | j# $¡  %ddg¡}|d |d  \| _&| _'| j(dd…  )d¡ dS )a2
  
        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.
        sharez : Axes3D, optional
            Other Axes to share z-limits with.
        proj_type : {'persp', 'ortho'}
            The projection type, default 'persp'.
        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.
        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)

        **kwargs
            Other optional keyword arguments:

            %(Axes3D:kwdoc)s
        Nç        g      ð?r   ÚdatalimZauto_add_to_figureFzSauto_add_to_figure is no longer supported for Axes3D. Use fig.add_axes(ax) instead.T)Zframeonr    Zmotion_notify_eventZbutton_press_eventZbutton_release_eventr   ©r   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ÚpopÚAttributeErrorÚsuperÚ__init__Úset_axis_offÚset_axis_onÚMÚ	fmt_zdataÚ
mouse_initÚfigureÚcanvasÚ	callbacksZ_connect_picklableÚ_on_moveÚ_button_pressÚ_button_releaseÚset_top_viewÚpatchZset_linewidthZtransLimitsÚinvertedÚ	transformÚ	_pseudo_wÚ	_pseudo_hZspinesZset_visible)ÚselfZfigZrectr   r   r   r   r   r    r!   r"   ÚargsÚkwargsZpseudo_bbox©Ú	__class__© ú?/tmp/pip-unpacked-wheel-7vhvci0g/mpl_toolkits/mplot3d/axes3d.pyr7   B   sj    8



ÿ ÿÿ ÿÿ

 ÿ
 ÿ
 ÿzAxes3D.__init__c                 C   s   d| _ d| _d S )NFT©Ú	_axis3donÚstale©rI   rN   rN   rO   r8   ¶   s    zAxes3D.set_axis_offc                 C   s   d| _ d| _d S )NTrP   rS   rN   rN   rO   r9   º   s    zAxes3D.set_axis_onc                 C   s   | j  |¡S )zs
        For artists in an Axes, if the zaxis has units support,
        convert *z* using zaxis unit type
        )ÚzaxisZconvert_units)rI   r   rN   rN   rO   Úconvert_zunits¾   s    zAxes3D.convert_zunitsc                 C   sN   d| j  }d| j  }d| j  }d| j  }| |f| j_| |f| j_d| _d S )Ngffffffî?gÍÌÌÌÌÌì?T)Ú_distZviewLimÚ	intervalxÚ	intervalyrR   )rI   ZxdwlZxdwZydwlZydwrN   rN   rO   rC   Å   s    



zAxes3D.set_top_viewc                 C   s(   t  | ¡| _t  | ¡| _t  | ¡| _dS )z5Init 3D axes; overrides creation of regular X/Y axes.N)r   ZXAxisÚxaxisZYAxisÚyaxisZZAxisrT   rS   rN   rN   rO   Ú
_init_axisÑ   s    zAxes3D._init_axisc                 C   s   | j S )z0Return the ``ZAxis`` (`~.axis3d.Axis`) instance.©rT   rS   rN   rN   rO   Ú	get_zaxis×   s    zAxes3D.get_zaxisrT   Zget_gridlinesZget_ticklinesz3.1rY   z3.8)ÚalternativeZremovalc                 C   s   | j S ©N)rY   rS   rN   rN   rO   Ú<lambda>ß   ó    zAxes3D.<lambda>rZ   c                 C   s   | j S r_   )rZ   rS   rN   rN   rO   r`   á   ra   c                 C   s   | j S r_   r\   rS   rN   rN   rO   r`   ã   ra   c                 C   s
   |   |¡S r_   )Ú
_unit_cube)rI   ÚvalsrN   rN   rO   Ú	unit_cubeå   s    zAxes3D.unit_cubec              
   C   s\   |p
|   ¡ \}}}}}}|||f|||f|||f|||f|||f|||f|||f|||fgS r_   )Ú
get_w_lims)rI   rc   ÚminxÚmaxxÚminyÚmaxyÚminzÚmaxzrN   rN   rO   rb   é   s    ùzAxes3D._unit_cubec                 C   s   |   ||¡S r_   ©Ú_tunit_cube©rI   rc   r:   rN   rN   rO   Ú
tunit_cubeô   s    zAxes3D.tunit_cubec                 C   s(   |d kr| j }|  |¡}t ||¡}|S r_   )r:   rb   r   Zproj_points)rI   rc   r:   ZxyzsZtcuberN   rN   rO   rm   ø   s
    
zAxes3D._tunit_cubec                 C   s   |   ||¡S r_   )Ú_tunit_edgesrn   rN   rN   rO   Útunit_edgesÿ   s    zAxes3D.tunit_edgesc                 C   s¼   |   ||¡}|d |d f|d |d f|d |d f|d |d f|d |d f|d |d f|d |d f|d |d f|d |d f|d |d f|d |d f|d |d fg}|S )	Nr   r   é   é   é   é   é   é   rl   )rI   rc   r:   ÚtcÚedgesrN   rN   rO   rp     s    ózAxes3D._tunit_edgesFc                    sp  t jd|d tƒ jd|||d || _|dkrl|  |¡}t | j 	¡ | j
 	¡ | j 	¡ g¡}tj|dd}| jdkrötj|dd}t|| | j|  ƒ}	|	| j }
t| j| j| jfƒD ]:\}}||kr¸||| |
| d	  || |
| d	  ƒ q¸nvt | j¡}|| ||< d
ddh |¡}|rb| ¡ }tj | j| ¡}tj || ¡}||  || 9  < |  |¡ dS )aq  
        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©Úaspectrz   )r€   Ú
adjustableÚanchorÚshare©r{   r|   r~   r}   r   ©Úaxisr$   ç       @r   rr   N)r   Úcheck_in_listr6   Ú
set_aspectÚ_aspectÚ_equal_aspect_axis_indicesÚnpÚarrayrY   Zget_view_intervalrZ   rT   Úptpr3   ÚmeanÚmaxÚ_box_aspectÚ	enumerateÚ
set_xlim3dÚ
set_ylim3dÚ
set_zlim3dÚ
differencer4   ÚlinalgÚnormÚset_box_aspect)rI   r€   r   r‚   rƒ   Ú
ax_indicesZview_intervalsrŽ   r   ÚscaleZdeltasÚiZset_limr    Zremaining_ax_indicesÚ	remainingZold_diagZnew_diagrL   rN   rO   r‰     sH    0ÿ   ÿ

þ

þ.zAxes3D.set_aspectc                 C   sP   g }|dkrdddg}n4|dkr*ddg}n"|dkr<ddg}n|dkrLddg}|S )a  
        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   rr   r|   r~   r}   rN   )rI   r€   rš   rN   rN   rO   r‹   j  s    


z!Axes3D._equal_aspect_axis_indicesr   )Úzoomc                C   st   |dkrt d|› dƒ‚|dkr0tjdtd}ntj|td}tjd|d |d	| tj |¡ 9 }|| _d
| _	dS )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)rt   rt   rs   ©Zdtype)rs   r   g‘Ir|Eý?T)
Ú
ValueErrorrŒ   ÚasarrayÚfloatr   Zcheck_shaper—   r˜   r‘   rR   )rI   r€   rž   rN   rN   rO   r™     s    zAxes3D.set_box_aspectc                 C   sp   |d kr| j dd}|  ¡ j}tj ¡  |¡}|j|j }d}| 	¡ }| 
|||¡}|  | |  ¡ |¡d¡ d S )NT)Úoriginalr   Úactive)Úget_positionZ
get_figureZtransSubfigureÚmtransformsr
   r*   ZtransformedÚheightÚwidthÚfrozenZshrunk_to_aspectZ_set_positionZanchoredZ
get_anchor)rI   ÚpositionZtransZbbZ
fig_aspectr    ZpbZpb1rN   rN   rO   Úapply_aspect¥  s    
zAxes3D.apply_aspectc           	         s:  |   ¡ sd S |  ¡  | j |¡ d| _|  ¡ }|  |r@|| |ƒnd ¡ |  ¡ | _dd„ | j	D ƒ}| j
rÚtdd„ | j ¡ D ƒƒd }| }}t|dd„ dd	D ]:}t|tjƒr¼||_|d7 }qœt|tjƒrœ||_|d7 }qœn|D ]}| ¡  qÞ| jr*| j ¡ D ]}| |¡ qþ| j ¡ D ]}| |¡ qtƒ  |¡ d S )
NFc                 s   s,   | ]$}t |tjtjfƒr| ¡ r|V  qd S r_   )Ú
isinstanceÚmcollÚ
CollectionÚmpatchesÚPatchÚget_visible)Ú.0ÚartistrN   rN   rO   Ú	<genexpr>Ë  s   þzAxes3D.draw.<locals>.<genexpr>c                 s   s   | ]}|  ¡ V  qd S r_   )Z
get_zorder)r²   r†   rN   rN   rO   r´   Ò  s   ÿr   c                 S   s   |   ¡ S r_   )Údo_3d_projection)r³   rN   rN   rO   r`   ×  ra   zAxes3D.draw.<locals>.<lambda>T)ÚkeyÚreverse)r±   Z_unstale_viewLimrD   ÚdrawÚ_frameonZget_axes_locatorr«   Úget_projr:   Ú	_childrenr!   r   Ú	_axis_mapÚvaluesÚsortedr¬   r­   r®   Úzorderr¯   r°   rµ   rQ   Z	draw_paner6   )	rI   ÚrendererÚlocatorZcollections_and_patchesZzorder_offsetZcollection_zorderZpatch_zorderr³   r†   rL   rN   rO   r¸   ¶  sH    
ÿÿÿþ


zAxes3D.drawc                 C   sh   |   ¡ }|  || j¡}|d d |d d k}|d d |d d k}|d d |d d k}|||fS )Nr   rr   rs   r   )re   rm   r:   )rI   rc   rx   ZxhighZyhighZzhighrN   rN   rO   Úget_axis_positionî  s    zAxes3D.get_axis_positionc                 K   s   dS )zK
        Not implemented in `~mpl_toolkits.mplot3d.axes3d.Axes3D`.
        NrN   )rI   ZxysrK   rN   rN   rO   Úupdate_datalimö  s    zAxes3D.update_datalimZ_get_autoscale_onZ_set_autoscale_onc                 C   s*   |dkrt dƒ‚|| _|  d¡ d| _dS )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    Ú_zmarginÚ_request_autoscale_viewrR   )rI   ÚmrN   rN   rO   Úset_zmarginÿ  s
    
zAxes3D.set_zmargin)r   r   r   Útightc                G   s  |r&|dk	s|dk	s|dk	r&t dƒ‚nBt|ƒdkrD|d  } }}n$t|ƒdkr\|\}}}n|rht dƒ‚|dkrª|dkrª|dkrª|dk	ršt d|›d	¡ | j| j| jfS |dk	r¼|  |¡ |dk	rÎ|  |¡ |dk	rà|  	|¡ | j
||dk	|dk	|dk	d
 dS )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   rs   zYMust pass a single positional argument for all margins, or one for each margin (x, y, z).Tzignoring tight=z in get mode)rÈ   ÚscalexÚscaleyÚscalez)Ú	TypeErrorÚlenr   Zwarn_externalÚ_xmarginÚ_ymarginrÄ   Zset_xmarginZset_ymarginrÇ   Úautoscale_view)rI   r   r   r   rÈ   ÚmarginsrN   rN   rO   rÑ     s0    



  þzAxes3D.marginsÚbothc                 C   s¼   |dkrd}d}d}nl|dkr6|   t|ƒ¡ |  ¡ }nd}|dkrZ|  t|ƒ¡ |  ¡ }nd}|dkr~|  t|ƒ¡ |  ¡ }nd}|r”| jd|d |r¦| jd	|d |r¸| jd
|d dS )a  
        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   rÒ   F)r   rÒ   ©r   rÒ   r   )rÈ   r   r   )Zset_autoscalex_onÚboolÚget_autoscalex_onZset_autoscaley_onÚget_autoscaley_onÚset_autoscalez_onÚget_autoscalez_onrÅ   )rI   Úenabler†   rÈ   rÉ   rÊ   rË   rN   rN   rO   Ú	autoscale9  s,    


zAxes3D.autoscalec                 C   s€   t  |¡t  |¡kr<| j t  t  |¡t  |¡g¡| ¡ n | j || ¡ | j || ¡ |d k	rt| j || ¡ |  	¡  d S r_   )
rŒ   Úshaper-   Zupdate_from_data_xyÚcolumn_stackÚravelZupdate_from_data_xZupdate_from_data_yr.   rÐ   )rI   ÚXÚYÚZÚhad_datarN   rN   rO   Úauto_scale_xyz\  s     ÿzAxes3D.auto_scale_xyzc                 C   s  |dkrL| j }|sZ| jD ]0}t|tjƒr.d}qt|tjtjfƒrd} qZqnt	|ƒ }| _ |râ|  
¡ râ| jd  ¡  | jj\}}| j ¡ }	|	 ||¡\}}| jdkrÂ|| | j }
||
8 }||
7 }|sÖ|	 ||¡\}}|  ||¡ |rr|  ¡ rr| jd  ¡  | jj\}}| j ¡ }| ||¡\}}| jdkrP|| | j }
||
8 }||
7 }|sf| ||¡\}}|  ||¡ |r|  ¡ r| jd  ¡  | jj\}}| j ¡ }| ||¡\}}| jdkrà|| | j }
||
8 }||
7 }|sö| ||¡\}}|  ||¡ dS )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   r   r   r   )Ú_tightr»   r¬   ÚmimageZ	AxesImageÚmlinesÚLine2Dr¯   r°   rÔ   rÕ   r1   Úcleanr-   rW   rY   Zget_major_locatorZnonsingularrÎ   Zview_limitsZ
set_xboundrÖ   rX   rZ   rÏ   Z
set_yboundrØ   r.   rT   rÄ   Ú
set_zbound)rI   rÈ   rÉ   rÊ   rË   rã   r³   Úx0Úx1ZxlocatorÚdeltaÚy0Úy1ZylocatorÚz0Úz1ZzlocatorrN   rN   rO   rÐ   j  s\    





zAxes3D.autoscale_viewc                 C   s4   |   ¡ \}}|  ¡ \}}|  ¡ \}}||||||fS )zGet 3D world limits.)Ú
get_xlim3dÚ
get_ylim3dÚ
get_zlim3d)rI   rf   rg   rh   ri   rj   rk   rN   rN   rO   re   ¨  s    zAxes3D.get_w_limsÚemit)ÚzminÚzmaxc                C   sf   |dkrt  |¡r|\}}|dk	r6|dk	r2tdƒ‚|}|dk	rR|dk	rNtdƒ‚|}| jj||||dS )zW
        Set 3D z limits.

        See `.Axes.set_ylim` for full documentation
        Nz$Cannot pass both 'bottom' and 'zmin'z!Cannot pass both 'top' and 'zmax'©ró   rz   )rŒ   ÚiterablerÌ   rT   Z_set_lim)rI   ÚbottomÚtopró   rz   rô   rõ   rN   rN   rO   Úset_zlim°  s    zAxes3D.set_zlimc                 C   s   t | jjƒS r_   )Útupler+   rW   rS   rN   rN   rO   Úget_xlimÈ  s    zAxes3D.get_xlimc                 C   s   t | jjƒS r_   )rû   r+   rX   rS   rN   rN   rO   Úget_ylimÌ  s    zAxes3D.get_ylimc                 C   s   t | jjƒS )zGet 3D z limits.)rû   r,   rW   rS   rN   rN   rO   Úget_zlimÐ  s    zAxes3D.get_zlimZ	get_scaleZ_set_axes_scalea“  
        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.
        r   r   Zget_ticklocsZ	set_ticksZget_majorticklabelsZget_minorticklabelsZget_ticklabelsZset_ticklabelszAxis.set_tickszAxes3D.set_zticks)Zdoc_subZ	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                 O   s   dS )z:Currently not implemented for 3D axes, and returns *None*.NrN   )rI   rJ   rK   rN   rN   rO   Úclabelý  s    zAxes3D.clabelc                 C   sl   d| _ |dkr| j| _n|| _|dkr0| j| _n|| _|dkrH| j| _n|| _tjt	dddd|d| _
dS )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.
        é
   Nr   r   rr   r   )Úvertical_axis)rV   r'   r   r&   r   r(   r   r   Zcheck_getitemÚdictÚ_vertical_axis)rI   r   r   r   r  rN   rN   rO   r/     s    1


 ÿzAxes3D.view_initc                 C   sv   t jddg|d |dkrH|dkr(d}n|dkr@td|› dƒ‚|| _n*|dtjfkrjtd|› d	|› ƒ‚tj| _dS )
aÐ  
        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   Z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)rI   r   r"   rN   rN   rO   r)   G  s    zAxes3D.set_proj_typec                 C   s   t  || jd ¡S )z1Roll arrays to match the different vertical axis.rr   )rŒ   r   r  )rI   ZarrrN   rN   rO   Ú_roll_to_verticalc  s    zAxes3D._roll_to_verticalc                 C   st  |   | j¡}tj|  ¡ |  ¡ |  ¡ žd|iŽ}d| }t t	 
| j¡¡}t t	 
| j¡¡}t |¡t |¡ }t |¡t |¡ }t |¡}|   |||g¡}	|| j|	  }
||
 }|
| _|tj |¡ | _|  |
¡\}}}|| _|| _|| _| jtjkrt ||||
¡}t | j | j¡}n:|| j|	 | j  }t ||||¡}t | j | j| j¡}t ||¡}t ||¡}|S )z?Create the projection matrix from the current viewing position.Z	pb_aspectç      à?)r  r‘   r   Zworld_transformationrð   rñ   rò   rŒ   Údeg2radr   Ú_norm_angler   r   ÚcosÚsinrV   Z_eyer—   r˜   Z_vvecÚ_calc_view_axesÚ_view_uÚ_view_vÚ_view_wr  r  Z_view_transformation_uvwZortho_transformationZpersp_transformationÚdot)rI   r    ZworldMÚRÚelev_radZazim_radÚp0Úp1Úp2ÚpsÚeyeÚvvecÚuÚvÚwZviewMZprojMZ	eye_focalZM0r:   rN   rN   rO   rº   g  sF    ýü

þzAxes3D.get_projrr   rs   c                 C   s:   d| _ t |¡ ¡ | _t |¡ ¡ | _t |¡ ¡ | _dS )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)rI   Ú
rotate_btnÚpan_btnÚzoom_btnrN   rN   rO   r<   ª  s    zAxes3D.mouse_initc                 C   s   | j g g g d dS )z<Disable mouse buttons for 3D rotation, panning, and zooming.)r"  r#  r$  N)r<   rS   rN   rN   rO   Údisable_mouse_rotation¿  s    zAxes3D.disable_mouse_rotationc                 C   s   dS )zV
        Return whether this Axes supports the zoom box button functionality.
        TrN   rS   rN   rN   rO   Úcan_zoomÃ  s    zAxes3D.can_zoomc                 C   s   dS )zQ
        Return whether this Axes supports the pan button functionality.
        TrN   rS   rN   rN   rO   Úcan_panÉ  s    zAxes3D.can_panc                 C   s   t jtjj|d | jdk	r.|| jk	r.tdƒ‚| jd  | |¡ || _|j	j
| j	_
|j	j| j	_| ¡ \}}| j||d| ¡ d |j	j| j	_dS )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.
        )ÚotherNzz-axis is already sharedr   Frö   )r   Zcheck_isinstanceÚmaxesÚ_baseZ	_AxesBaser0   r    r1   r2   rT   ÚmajorÚminorrþ   rú   rØ   Z_scale)rI   r(  rî   rï   rN   rN   rO   r   Ï  s    zAxes3D.sharezc                    s>   t ƒ  ¡  | jtjkr$tjd | _nd| _|  tjd ¡ d S )Nzaxes.zmarginr#   zaxes3d.grid)	r6   Úclearr  rŒ   r  ÚmplÚrcParamsrÄ   ÚgridrS   rL   rN   rO   r-  â  s
    
zAxes3D.clearc                 C   sT   |j | krP|j| _|j|j | _| _t| jj	dƒ}|rP| 
¡ d krP| jj	j ¡  d S ©NÚtoolbar)ÚinaxesÚbuttonr  ÚxdataÚydataÚ_sxÚ_syÚgetattrr=   r>   Z
_nav_stackr2  Úpush_current©rI   Úeventr2  rN   rN   rO   rA   ë  s    
zAxes3D._button_pressc                 C   s6   d | _ t| jjdƒ}|r2|  ¡ d kr2| jjj ¡  d S r1  )r  r9  r=   r>   Úget_navigate_moder2  r:  r;  rN   rN   rO   rB   ó  s    zAxes3D._button_releasec                 C   s"   |   ¡ |  ¡ |  ¡ | j| j| jfS r_   )rü   rý   rþ   r   r   r   rS   rN   rN   rO   Ú	_get_viewû  s
      ÿzAxes3D._get_viewc                 C   s6   |\}}}}}}| j |||d || _|| _|| _d S )Nr   )Úsetr   r   r   )rI   Úviewr   r   r   r   r   r   rN   rN   rO   Ú	_set_view   s
    zAxes3D._set_viewc              	   C   sB   z|   |¡W S  ttfk
r<   | j ¡ j}||ƒ}| Y S X dS )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
        N)r;   r5   rÌ   rT   Zget_major_formatterZformat_data_short)rI   r   ÚfuncÚvalrN   rN   rO   Úformat_zdata  s    zAxes3D.format_zdatac                    s"  | j dkrdS | j| jkrdt | j¡}t | j¡}t | j¡}d|d›d|d›d|d›d dd	¡S t	|  
¡ ‡ ‡fd
d„d\}}|\}}	}
|\}}}t |ˆ  |	ˆ ¡}t |ˆ  |ˆ ¡}|| }|| |
 || |  }t ˆ ˆ|| j ¡\}}}|  |¡}|  |¡}|  |¡}d|||f S )zå
        Given the 2D view coordinates attempt to guess a 3D coordinate.
        Looks for the nearest edge to the point and then assumes that
        the point is at the same z location as the nearest point on the edge.
        NÚ z
elevation=z.0fu   Â°, azimuth=u	   Â°, roll=õ   Â°ú-u   âˆ’c                    s*   t  ˆ ˆf| d d d… | d d d… ¡S )Nr   rr   r   )r   Z_line2d_seg_dist)Zedge©ÚxdÚydrN   rO   r`   +  s     ÿz%Axes3D.format_coord.<locals>.<lambda>)r¶   zx=%s, y=%s, z=%s)r:   r  r  r   r	  r   r   r   ÚreplaceÚminrp   rŒ   Úhypotr   Zinv_transformZformat_xdataZformat_ydatarD  )rI   rI  rJ  Z	norm_elevZ	norm_azimZ	norm_rollr  r  ré   rì   rî   rê   rí   rï   Zd0Úd1Údtr   r   r   ÚxsÚysÚzsrN   rH  rO   Úformat_coord  s0    
 ýÿ





zAxes3D.format_coordc                 C   s°  | j s
dS |  ¡ dk	rdS | jdkr(dS |j|j }}|dksH|j| krLdS || j || j  }}| j}| j	}| j | j
kr|dkr|dkrdS t | j¡}||  d t |¡ || d t |¡  }	||  d t |¡ || d t |¡  }
| j|	 | _| j|
 | _d| _nz| j | jkrj| j | j| jg¡\}}|  ||d¡ |  dd|j|j¡ |  ¡  n(| j | jkr’|||  }|  |||¡ || | _| _| jj ¡  dS )z¡
        Mouse moving.

        By default, button-1 rotates, button-2 pans, and button-3 zooms;
        these buttons can be modified via `mouse_init`.
        Nr   é´   Trr   ) r  r=  r:   r5  r6  r3  r7  r8  rG   rH   r  rŒ   r  r   r
  r  r   r   rR   r   Z	transDatarF   Ú	start_panÚdrag_panr   r   Úend_panr!  Ú_scale_axis_limitsr=   r>   Z	draw_idle)rI   r<  r   r   ÚdxÚdyr  Úhr   ZdelevZdazimZpxÚpyr›   rN   rN   rO   r@   =  s>    
..
zAxes3D._on_movec                 C   sP  | j }|j ||f|j|jfg¡\\}}\}}	|| | _| _|  |||¡ || ||	  }
}d}|dkrnd}n|dkrzd}
|
dkrŽ|dkrŽd S t 	| j
| j| jg¡}| | j | j }|jt 	|
||g¡ }|  ¡ \}}}}}}|| |d  }|| |d  }|| |d  }|  || || ¡ |  || || ¡ |  || || ¡ d S )Nr   r   r   r   rr   )Z
_pan_startZtrans_inverserF   r   r   r7  r8  rU  rŒ   r   r  r  r  r‘   rV   ÚTre   r“   r”   r•   )rI   r4  r¶   r   r   Úpr5  r6  Zxdata_startZydata_startZduZdvZdwr  Zduvw_projectedrf   rg   rh   ri   rj   rk   rY  rZ  ÚdzrN   rN   rO   rV  z  s0    ÿzAxes3D.drag_panc           	      C   s~   t  t | j¡¡}t  t | j¡¡}d|  | j¡ }t  d¡}t	|ƒt j
d krTdnd|| j< t ||||¡\}}}|||fS )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  rs   rr   éÿÿÿÿr   )rŒ   r  r   r	  r   r   r  r‘   ÚzerosÚabsÚpir  r   Z
_view_axes)	rI   r  r  Zroll_radr  ÚVr  r  r  rN   rN   rO   r  ž  s    
 zAxes3D._calc_view_axesÚinc                 C   s–  |\}}}}	|dkr.| j jd }| j jd }	n |dkrN| j jd }| j jd }t t||gƒ| j jd | j jd ¡\}}t t||	gƒ| j jd | j jd ¡\}}	|| d }
||	 d }| j jd | j jd  d }| j jd | j jd  d }|  |
|d¡ |  dd||¡ |  ¡  t	|| ƒ}t	||	 ƒ}|| j jd | j jd   }|| j jd | j jd   }t||ƒ}|dkr„d| }|  
|||¡ dS )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   rr   NÚout)ÚbboxrL  r   rŒ   Zclipr¾   rU  rV  rW  rb  Ú_zoom_data_limits)rI   rg  Ú	directionÚmodeZtwinxZtwinyZstart_xZstart_yZstop_xZstop_yZzoom_center_xZzoom_center_yZax_center_xZax_center_yrY  rZ  Úscale_uÚscale_vr›   rN   rN   rO   Ú_set_view_from_bbox´  s<    
 
ÿ
 
ÿ

zAxes3D._set_view_from_bboxc           	      C   s²   t  |||g¡}t  ||¡s”t  | j| j| jg¡}|t  d¡ }t jj|j	| dd}| j
dkr”|  | j
¡}t  t  || d ¡¡}|| | ||< |  |d |d |d ¡ dS )aò  
        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).
        rs   r   r…   r„   r   rr   N)rŒ   r   Zallcloser  r  r  r  r—   r˜   r]  rŠ   r‹   Zargminrb  rX  )	rI   rk  rl  Zscale_wr›   r  ÚSZax_idxsZmin_ax_idxsrN   rN   rO   rh  ä  s    
zAxes3D._zoom_data_limitsc                 C   s´   |   ¡ \}}}}}}	|| d }
|| d }|	| d }|| | }|| | }|	| | }|  |
|d  |
|d  ¡ |  ||d  ||d  ¡ |  ||d  ||d  ¡ dS )a´  
        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.
        rr   N)re   r“   r”   r•   )rI   Zscale_xZscale_yZscale_zrf   rg   rh   ri   rj   rk   ZcxÚcyÚczrY  rZ  r_  rN   rN   rO   rX  
  s    zAxes3D._scale_axis_limitsc                 K   s"   |dk	r|| j _| j j||f|ŽS )zI
        Set zlabel.  See doc for `.set_ylabel` for description.
        N)rT   ÚlabelpadZset_label_text)rI   ZzlabelÚfontdictrq  rK   rN   rN   rO   Ú
set_zlabel)  s    zAxes3D.set_zlabelc                 C   s   | j  ¡ }| ¡ S )z.
        Get the z-label text string.
        )rT   Z	get_labelZget_text)rI   ÚlabelrN   rN   rO   Ú
get_zlabel1  s    
zAxes3D.get_zlabelc                 C   s   | j S )z)Get whether the 3D axes panels are drawn.)r¹   rS   rN   rN   rO   Úget_frame_on:  s    zAxes3D.get_frame_onc                 C   s   t |ƒ| _d| _dS )zs
        Set whether the 3D axes panels are drawn.

        Parameters
        ----------
        b : bool
        TN)rÔ   r¹   rR   )rI   ÚbrN   rN   rO   Úset_frame_on>  s    
zAxes3D.set_frame_onc                 K   s   t |ƒrd}|| _d| _dS )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Í   Z
_draw_gridrR   )rI   ZvisiblerK   rN   rN   rO   r0  I  s    zAxes3D.gridc                    s€   t jddddg|d |dkr.tƒ j|f|Ž |dkr|t|ƒ}| dd	¡ | d
d	¡ | dd	¡ | dd	¡ | jjf |Ž d	S )ax  
        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   rÒ   r…   )r   r   rÒ   rÓ   rù   Nrø   ZlabeltopZlabelbottom)r   rˆ   r6   Útick_paramsr  r4   rT   Zset_tick_params)rI   r†   rK   ZzkwrL   rN   rO   ry  Y  s    zAxes3D.tick_paramsc                 C   s    |   ¡ \}}| j||dd dS )z$
        Invert the z-axis.
        N©rz   )rþ   rú   ©rI   rø   rù   rN   rN   rO   Úinvert_zaxisw  s    zAxes3D.invert_zaxisZget_invertedc                 C   s(   |   ¡ \}}||k r||fS ||fS dS )zP
        Return the lower and upper z-axis bounds, in increasing order.
        N)rþ   r{  rN   rN   rO   Ú
get_zbound€  s    zAxes3D.get_zboundc                 C   sd   |dkrt  |¡r|\}}|  ¡ \}}|dkr2|}|dkr>|}| jt||ft|  ¡ ƒddd dS )zä
        Set the lower and upper numerical bounds of the z-axis.

        This method will honor axes inversion regardless of parameter order.
        It will not change the autoscaling setting (`.get_autoscalez_on()`).
        N)r·   rz  )rŒ   r÷   r}  rú   r¾   rÔ   Úzaxis_inverted)rI   ÚlowerÚupperZ	old_lowerZ	old_upperrN   rN   rO   rè   Š  s    
ÿþzAxes3D.set_zboundc                    s&   t ƒ j|||f|Ž}t |||¡ |S )zÌ
        Add text to the plot.

        Keyword arguments will be passed on to `.Axes.text`, except for the
        *zdir* keyword, which sets the direction to be used as the z
        direction.
        )r6   Útextr   Ztext_2d_to_3d)rI   r   r   r   ÚsÚzdirrK   r  rL   rN   rO   r  ž  s    zAxes3D.text©rƒ  c          
         s¬   |   ¡ }|r4t|d tƒs4|^}}d|kr@tdƒ‚n| dd¡}t |t |¡¡}tƒ j	||f|ž|Ž}|D ]}	t
j|	||d qlt
 ||||¡\}}}|  ||||¡ |S )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.
        **kwargs
            Other arguments are forwarded to `matplotlib.axes.Axes.plot`.
        r   rR  z+plot() for multiple values for argument 'z'©rR  rƒ  )Úhas_datar¬   ÚstrrÌ   r4   rŒ   Úbroadcast_torÛ   r6   Úplotr   Úline_2d_to_3dÚjuggle_axesrâ   )
rI   rP  rQ  rƒ  rJ   rK   rá   rR  ÚlinesÚlinerL   rN   rO   r‰  ­  s    
zAxes3D.plot)r˜   ÚvminÚvmaxÚlightsourcec          !         s  |   ¡ }	|jdkrtdƒ‚t |¡}t |||¡\}}}|j\}
}d|kpPd|k}d|kp`d|k}|rr|rrtdƒ‚| dd¡‰| dd¡‰| dd	¡}| dd	¡}t	j
d
 r²|}n| }|rìttt |
| ¡dƒƒ‰ttt || ¡dƒƒ‰| dd¡}|dkr2| dd¡}|dkr"| j ¡ }t t |¡¡}| dd¡}| d|dk¡}|dkr`tdƒ‚g }|
d ˆ dkr¸|d ˆ dkr¸|dkr¸tj‡‡fdd„|||fD ƒdd}nÜttd|
d ˆƒƒ|
d g }ttd|d ˆƒƒ|d g }g }t|dd… |dd… ƒD ]€\‰‰t|dd… |dd… ƒD ]Z\‰ ‰‡ ‡‡‡fdd„|||fD ƒ}t |¡j}| |¡ |dk	r4| |ˆ ˆ  ¡ q4qt|tjƒr²t |¡ ¡ r g }g }t ||¡D ]F\}}t |¡t |¡jdd  }t |ƒrÆ| |¡ | |¡ qÆ|}|dk	r |}|dk	rHt!j"|f||||dœ|—Ž}n¢|rÐt!j"|f|Ž}t|tjƒr||d j#dd} nt dd„ |D ƒ¡} | $| ¡ |dk	s®|dk	rº| %||¡ |dk	rê| &|¡ nt!j"|f|||dœ|—Ž}|  '|¡ |  (||||	¡ |S )a7	  
        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 : color-like
            Color of the surface patches.

        cmap : Colormap
            Colormap of the surface patches.

        facecolors : array-like of colors.
            Colors of each individual patch.

        norm : Normalize
            Normalization for the colormap.

        vmin, vmax : float
            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`
            The lightsource to use when *shade* is True.

        **kwargs
            Other keyword arguments are forwarded to `.Poly3DCollection`.
        rr   ú!Argument Z must be 2-dimensional.ÚrstrideÚcstrideÚrcountÚccountú.Cannot specify both stride and count argumentsr   é2   ú_internal.classic_moder   Ú
facecolorsNÚcolorÚcmapÚshadezshade cannot be None.r   c                    s   g | ]}t  |ˆˆ ¡‘qS rN   )r   Z_array_patch_perimeters©r²   Úa)r“  r’  rN   rO   Ú
<listcomp>R  s   ÿz'Axes3D.plot_surface.<locals>.<listcomp>r`  r…   c              	      s.   g | ]&}t  |ˆˆd  …ˆ ˆd  …f ¡‘qS )r   )r   Z_array_perimeterr  )ÚcsÚcs_nextÚrsÚrs_nextrN   rO   rŸ  ]  s   ÿ)Ú
edgecolorsr™  rœ  r  ).rr   c                 S   s    g | ]}|d d …df   ¡ ‘qS ©Nrr   )r   )r²   r  rN   rN   rO   rŸ  ‹  s     )r™  rœ  r  ))r†  Úndimr    r   Z_to_unmasked_float_arrayrŒ   Úbroadcast_arraysrÛ   r4   r.  r/  Úintr   ÚceilÚ
_get_linesÚget_next_colorr   ÚmcolorsÚto_rgbaÚgetÚstackÚlistÚrangeÚzipr]  Úappendr¬   ZndarrayÚisnanÚanyÚ	itertoolsÚzip_longestrÍ   r   ÚPoly3DCollectionr   Ú	set_arrayÚset_climÚset_normÚadd_collectionrâ   )!rI   rÞ   rß   rà   r˜   rŽ  r  r  rK   rá   ÚrowsÚcolsÚ
has_strideÚ	has_countr”  r•  Zcompute_stridesZfcolorsrš  r›  rœ  ZcolsetÚpolysZrow_indsZcol_indsr  Z	new_polysZ
new_colsetr^  ÚcolZnew_polyÚpolycÚavg_zrN   )r   r¡  r“  r¢  r£  r’  rO   Úplot_surfaceØ  sÄ    F







ÿþÿý""ý





ÿ  þþ

ÿ þþ
zAxes3D.plot_surfacec                    sÔ  |   ¡ }ˆjdkrtdƒ‚t ˆ ˆˆ¡\‰ ‰‰ˆj\}}d|kpFd|k}d|kpVd|k}	|rh|	rhtdƒ‚| dd¡}
| dd¡}| dd	¡}| dd	¡}tjd
 rè|	ræ|rÂt	t
t || ¡dƒƒnd}
|rât	t
t || ¡dƒƒnd}nJ|s2|rt	t
t || ¡dƒƒnd}
|r.t	t
t || ¡dƒƒnd}t ˆ ¡t ˆ¡t ˆ¡  ‰‰‰|
r–ttd||
ƒƒ}|dkrš|d |d krš||d g7 }ng }|rÜttd||ƒƒ}|dkrà|d |d krà||d g7 }ng }|
dkrü|dkrütdƒ‚ˆjdkrg }g }‡ fdd„|D ƒ}‡fdd„|D ƒ}‡fdd„|D ƒ}‡fdd„|D ƒ}‡fdd„|D ƒ}‡fdd„|D ƒ}dd„ t|||ƒD ƒdd„ t|||ƒD ƒ }tj|f|Ž}|  |¡ |  ˆ ˆˆ|¡ |S )a¿  
        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.

        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`.
        rr   r‘  r’  r“  r”  r•  r–  r   r—  r˜  r   r`  z*Either rstride or cstride must be non zeroc                    s   g | ]}ˆ | ‘qS rN   rN   ©r²   rœ   )rÞ   rN   rO   rŸ  þ  s     z)Axes3D.plot_wireframe.<locals>.<listcomp>c                    s   g | ]}ˆ | ‘qS rN   rN   rÆ  )rß   rN   rO   rŸ  ÿ  s     c                    s   g | ]}ˆ | ‘qS rN   rN   rÆ  )rà   rN   rO   rŸ     s     c                    s   g | ]}ˆ | ‘qS rN   rN   rÆ  )ÚtXrN   rO   rŸ    s     c                    s   g | ]}ˆ | ‘qS rN   rN   rÆ  )ÚtYrN   rO   rŸ    s     c                    s   g | ]}ˆ | ‘qS rN   rN   rÆ  )ÚtZrN   rO   rŸ    s     c                 S   s"   g | ]\}}}t t|||ƒƒ‘qS rN   ©r°  r²  ©r²   ÚxlÚylÚzlrN   rN   rO   rŸ    s   ÿc                 S   s"   g | ]\}}}t t|||ƒƒ‘qS rN   rÊ  rË  rN   rN   rO   rŸ    s   ÿ)r†  r¦  r    rŒ   r§  rÛ   r4   r.  r/  r¨  r   r©  Z	transposer°  r±  Úsizer²  r   ÚLine3DCollectionr¼  râ   )rI   rÞ   rß   rà   rK   rá   r½  r¾  r¿  rÀ  r’  r“  r”  r•  ZriiZciiZxlinesZylinesZzlinesZtxlinesZtylinesZtzlinesrŒ  ÚlinecrN   )rÞ   rß   rà   rÇ  rÈ  rÉ  rO   Úplot_wireframe›  sj    &


 """"
ÿ
ÿþ
zAxes3D.plot_wireframe)rš  r˜   rŽ  r  r  c                O   s|  |   ¡ }|dkr| j ¡ }t t |¡¡}| dd¡}	| d|	dk¡}
t	j
||Ž\}}}z| d¡}W n tk
r‚   |^}}Y nX t |¡}| ¡ }|j| }|j| }|| }tj|||fdd}|	r<tj|f|ž|Ž}|dd…dd…df jdd}| |¡ |dk	s|dk	r&| ||¡ |dk	rZ| |¡ ntj|f|ž|
||d	œ|—Ž}|  |¡ |  |j|j||¡ |S )
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 : Normalize
            An instance of Normalize to map values to colors.
        vmin, vmax : float, default: None
            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`
            The lightsource to use when *shade* is True.
        **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
        Nr›  rœ  rà   r`  r…   rr   r   )rœ  r  r™  )r†  rª  r«  rŒ   r   r¬  r­  r®  r4   r   Úget_from_args_and_kwargsÚKeyErrorr¡   Zget_masked_trianglesr   r   r¯  r   r¸  r   r¹  rº  r»  r¼  râ   )rI   rš  r˜   rŽ  r  r  rJ   rK   rá   r›  rœ  Útrir   Ú	trianglesZxtZytZztÚvertsrÃ  rÄ  rN   rN   rO   Úplot_trisurf  sP    5

ÿ




ÿÿ þþ
zAxes3D.plot_trisurfru   c              	   C   sl  |j }|j}|d |d  d }t||ƒD ]&\}}| ¡ }|sBq*t ||| ¡}	t ||| ¡}
| ¡ d }tt|	d ƒ| ƒ}|dkr¢t|	d ƒdkr*d}nq*g }t|	d ƒd |d  }t	t|ƒd ƒD ]R}t|| ƒ}t|d | ƒ}| 
|	d | |	d | |
d | |
d | g¡ qÎt |¡}tj|||dd}| |¡ |  |¡ q*|D ]}| ¡  qXdS )z4
        Extend a contour in 3D by creating
        r   r   rr   T)r™  r¤  rœ  N)ÚlevelsÚcollectionsr²  Ú	get_pathsr   Z_paths_to_3d_segmentsZget_edgecolorÚroundrÍ   r±  r³  rŒ   r   r¸  Úset_sort_zposÚadd_collection3dÚremove)rI   ÚcsetÚstriderÙ  Zcollsr_  r   rÑ  ÚpathsZtopvertsZbotvertsrš  ZnstepsZ	polyvertsZstepsizerœ   Úi1Úi2ZpolycolrÂ  rN   rN   rO   Ú_3d_extend_contourr  sF    


ý
ý
zAxes3D._3d_extend_contourc                 C   sR   d| }|r|   ||¡ n4t|j|jƒD ]$\}}|d k	r<|}tj|||d q(d S )NrG  r„  )rå  r²  rÙ  rÚ  r   Úline_collection_2d_to_3d)rI   rà  Úextend3drá  rƒ  Úoffsetr   rÑ  rN   rN   rO   Úadd_contour_set¡  s    zAxes3D.add_contour_setc                 C   s   | j |||d d S )N©rƒ  rè  )Ú_add_contourf_set)rI   rà  rƒ  rè  rN   rN   rO   Úadd_contourf_set¬  s    zAxes3D.add_contourf_setc           	      C   sÐ   d| }|j dd… t |j ¡d  }|jr\|j d t |j dd… ¡d  }t |d|¡}|jr|j d t |j dd… ¡d  }t ||¡}t||jƒD ].\}}|dk	r°|}t	j
|||d | |¡ qœ|S )z…
        Returns
        -------
        levels : `numpy.ndarray`
            Levels at which the filled contours are added.
        rG  Nr`  rr   r   éþÿÿÿr„  )rÙ  rŒ   ÚdiffZ_extend_minÚinsertZ_extend_maxr³  r²  rÚ  r   Úpoly_collection_2d_to_3drÝ  )	rI   rà  rƒ  rè  Z	midpointsZ	min_levelZ	max_levelr   rÑ  rN   rN   rO   rë  ¯  s    ""zAxes3D._add_contourf_set)rç  rá  rƒ  rè  c                   s\   |   ¡ }
t ||||¡\}}}tƒ j|||f|ž|	Ž}|  |||||¡ |  ||||
¡ |S )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
            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*.
        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_axesr6   Úcontourré  râ   )rI   rÞ   rß   rà   rç  rá  rƒ  rè  rJ   rK   rá   ÚjXÚjYÚjZrà  rL   rN   rO   rò  È  s    zAxes3D.contourc                   s¦   |   ¡ }tj||Ž\}}}|j}	|j}
d|kr:| d¡}n|^}}t |	|
||¡\}}}t|||j|j	ƒ}t
ƒ j||f|ž|Ž}|  |||||¡ |  |	|
||¡ |S )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
            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*.
        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   r4   r   rñ  rÖ  Úmaskr6   Ú
tricontourré  râ   )rI   rç  rá  rƒ  rè  rJ   rK   rá   rÕ  rÞ   rß   rà   ró  rô  rõ  rà  rL   rN   rO   r÷  ð  s       ÿ
zAxes3D.tricontourc                    s:   d|d|d|||i‰ ‡ fdd„dD ƒ}| j ||fžŽ  d S )Nr   r   r   c                    s(   g | ] }t  ˆ | ¡t  ˆ | ¡f‘qS rN   ©rŒ   ZnanminZnanmax)r²   Zdim©Zdim_valsrN   rO   rŸ  +  s   ÿz/Axes3D._auto_scale_contourf.<locals>.<listcomp>r   )râ   )rI   rÞ   rß   rà   rƒ  rÙ  rá   ZlimitsrN   rù  rO   Ú_auto_scale_contourf%  s
    
ÿzAxes3D._auto_scale_contourfrê  c                   s\   |   ¡ }t ||||¡\}	}
}tƒ j|	|
|f|ž|Ž}|  |||¡}|  ||||||¡ |S )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*.
        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ñ  r6   Úcontourfrë  rú  )rI   rÞ   rß   rà   rƒ  rè  rJ   rK   rá   ró  rô  rõ  rà  rÙ  rL   rN   rO   rû  /  s    zAxes3D.contourfc                   s¦   |   ¡ }tj||Ž\}}}|j}|j}d|kr:| d¡}	n|^}	}t |||	|¡\}
}}t|
||j|j	ƒ}t
ƒ j||f|ž|Ž}|  |||¡}|  |||	|||¡ |S )aW  
        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.
        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   r4   r   rñ  rÖ  rö  r6   Útricontourfrë  rú  )rI   rƒ  rè  rJ   rK   rá   rÕ  rÞ   rß   rà   ró  rô  rõ  rà  rÙ  rL   rN   rO   rü  Q  s      ÿ
zAxes3D.tricontourfc                    sª   t  |¡}|jrt  |¡nd}t|ƒtjkrHtj|||d | 	|¡ nRt|ƒtj
krrtj|||d | 	|¡ n(t|ƒtjkrštj|||d | 	|¡ tƒ  |¡}|S )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.

        Supported are:

        - PolyCollection
        - LineCollection
        - PatchCollection
        r   r…  )rŒ   r  rÏ  rL  Útyper­   ZPolyCollectionr   rð  rÝ  ZLineCollectionræ  ZPatchCollectionÚpatch_collection_2d_to_3dr6   r¼  )rI   rÂ  rR  rƒ  ZzvalsZzsortvalZ
collectionrL   rN   rO   rÞ  ‚  s    
ÿ
zAxes3D.add_collection3drP  rQ  rR  r‚  r¤  ÚcÚ	facecolorr™  rš  )Zreplace_namesé   c                    sÌ   |   ¡ }
|}tjdd„ |||fD ƒŽ \}}}tj |¡}t |||||¡\}}}}}t ||¡rh| ¡ }t	ƒ j
||f|ž||dœ|	—Ž}tj||||d | jdk r¸|jdkr¸|  d¡ |  ||||
¡ |S )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 : 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.
        data : indexable object, optional
            DATA_PARAMETER_PLACEHOLDER
        **kwargs
            All other keyword arguments are passed on to `~.axes.Axes.scatter`.

        Returns
        -------
        paths : `~matplotlib.collections.PathCollection`
        c                 S   s"   g | ]}t  t j |t j¡¡‘qS rN   )rŒ   rÝ   ÚmaÚfilledÚnan)r²   ÚtrN   rN   rO   rŸ  Ù  s     z"Axes3D.scatter.<locals>.<listcomp>)r‚  rÿ  )rR  rƒ  Ú
depthshadeçš™™™™™©?r   )r†  rŒ   r§  r  rÝ   r   Zdelete_masked_pointsZmay_share_memoryÚcopyr6   Úscatterr   rþ  rÄ   rÏ  rÇ   râ   )rI   rP  rQ  rR  rƒ  r‚  rÿ  r  rJ   rK   rá   Zzs_origÚpatchesrL   rN   rO   r	  £  s"    2ÿ
 
ÿ
zAxes3D.scatterc                    sä   |   ¡ }tƒ j||f|ž|Ž}t |t|ƒ¡}g }	g }
t||ƒD ]T\}}t |¡}|	| 	¡ 7 }	|
|gt|ƒ 7 }
t 
|||¡ d|kr@| |d ¡ q@t|	ƒdkr°t|	Ž \}}n
g g  }}t |||
|¡\}}}
|  |||
|¡ |S )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
            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').
        data : indexable object, optional
            DATA_PARAMETER_PLACEHOLDER
        **kwargs
            Other keyword arguments are forwarded to
            `matplotlib.axes.Axes.bar`.

        Returns
        -------
        mpl_toolkits.mplot3d.art3d.Patch3DCollection
        Úalphar   )r†  r6   ÚbarrŒ   rˆ  rÍ   r²  r   Z_get_patch_vertsr  Zpatch_2d_to_3dZ	set_alphar‹  râ   )rI   Úleftr§   rR  rƒ  rJ   rK   rá   r
  r×  Zverts_zsr^  r   ÚvsrP  rQ  rL   rN   rO   r  ï  s$    

z
Axes3D.barÚaveragec                 O   sæ  |   ¡ }t t |¡|||||¡\}}}}}}t |¡}t || ¡}t |¡}t || ¡}t |¡}t || ¡}t ddddddg¡}t |j|j ¡}d||fd||fd	||ffD ]J\}}}|d
tj	tj	f }|d
tj	tj	f }|||d
|f   |d
|f< qº| 
d|jd	d…  ¡}g }|dkr8| j ¡ g}tt |¡ƒ}t|ƒt|ƒkrv|D ]}| |gd ¡ q\n&|}t|ƒt|ƒk rœ|dt|ƒ 9 }tj|f|ž|||	|
dœ|—Ž}|  |¡ |  ||f||f||f|¡ |S )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 : str, optional
            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`
            The lightsource to use when *shade* is True.

        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   rr   .)r`  Nrv   )Úzsortr™  rœ  r  )r†  rŒ   r§  r  rL  r   r   ÚemptyrÛ   ZnewaxisÚreshapeÚ_get_patches_for_fillr«  r°  r¬  Zto_rgba_arrayrÍ   Úextendr   r¸  r¼  râ   )rI   r   r   r   rY  rZ  r_  rš  r  rœ  r  rJ   rK   rá   rf   rg   rh   ri   rj   rk   ZcuboidrÁ  rœ   r^  Zdpr™  rÿ  rÂ  rN   rN   rO   Úbar3d&	  sh    >     ÿ


Û.&
ûüû
zAxes3D.bar3dÚcenterc                    s<   t ƒ j|f||dœ|—Ž}| j ¡ \}}| j d| ¡ |S )N)rr  Úlocgq=
×£pí?)r6   Ú	set_titleÚtitler¥   Zset_y)rI   rt  rr  r  rK   Úretr   r   rL   rN   rO   r   Ç	  s    zAxes3D.set_titleg333333Ó?Útail)ÚlengthÚarrow_length_ratioÚpivotÚ	normalizec                   sN  ddd„}|   ¡ }||||||g}dd„ |D ƒ}tj||žŽ }|dd… }|dd… }|r|t tj|¡‰ ‡ fdd„|D ƒ}nd	d„ |D ƒ}td
d„ |D ƒƒr¸tjg f|Ž}|  	|¡ |S tj
d|gtd}|| }tjdddg|	d |	dkrø||8 }n|	dkr||d 8 }t |dd… ¡}t |dd… ¡ t¡}tjj|dd}|dk‰ |ˆ  }|
rv|ˆ  |ˆ   d¡ }n|ˆ  }t|ƒdkrú|tj ||¡  dd¡}||ƒ}|dd…dd…f tj ||¡ }| t|ƒddf¡}| dd¡}||•}ng }tj|f|Ž}|  	|¡ |  |dd…df |dd…df |dd…df |¡ |S )aF  
        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*.

        data : indexable object, optional
            DATA_PARAMETER_PLACEHOLDER

        **kwargs
            Any additional keyword arguments are delegated to
            :class:`.Line3DCollection`
        é   c              
   S   sl  | d d …df }| d d …df }t jj| d d …d d…f dd}t j|||dkt  |¡d}t j| ||dkt  |¡d}t |¡}t |¡}t 	|¡}	t  
||d d|   || d|  ||	 g|| d|  ||d d|   | |	 g| |	 ||	 t  ||¡gg¡}
|
 ¡ }|ddddgddddgf  d9  < t  d|
| ¡}t  d|| ¡}t j||gdd}|S )Nr   r   rr   r…   )Úwhererf  r`  zij...,...j->...i)rŒ   r—   r˜   ÚdivideZ
zeros_likeZ	ones_likeÚmathÚradiansr
  r  r   Z	full_liker  Zeinsumr¯  )ÚUVWZangler   r   r˜   Zx_pZy_pÚrarÿ  r‚  ZRposZRnegZ	Rpos_vecsZ	Rneg_vecsÚ	head_dirsrN   rN   rO   Úcalc_arrowsù	  s(     


(*þÿ$z"Axes3D.quiver.<locals>.calc_arrowsc                 S   s    g | ]}t |tjjƒr|j‘qS rN   )r¬   rŒ   r  ZMaskedArrayrö  ©r²   ÚkrN   rN   rO   rŸ  
  s    ÿz!Axes3D.quiver.<locals>.<listcomp>Nrv   c                    s    g | ]}t jj|ˆ d  ¡ ‘qS )©rö  )rŒ   r  r   Ú
compressedr1  r3  rN   rO   rŸ  "
  s   ÿc                 S   s   g | ]}t  |¡‘qS rN   )rŒ   rÝ   r1  rN   rN   rO   rŸ  %
  s     c                 s   s   | ]}t |ƒd kV  qdS )r   N)rÍ   )r²   r  rN   rN   rO   r´   '
  s     z Axes3D.quiver.<locals>.<genexpr>r#   rŸ   r#  ZmiddleZtip)r&  rr   rs   r   r…   r   )r`  r   r`  )r(  )r†  rŒ   r§  Ú	functoolsÚreduceÚ
logical_orrµ  r   rÐ  r¼  r   r¢   r   rˆ   rÜ   Úastyper—   r˜   r  rÍ   ÚmultiplyÚouterZswapaxesrâ   )rI   rÞ   rß   rà   ÚUrd  ÚWr$  r%  r&  r'  rK   r0  rá   Z
input_argsÚmasksZbcastrÑ  Zshaft_dtZarrow_dtZXYZr-  r˜   Zshaftsr/  ZheadsrŒ  rN   r3  rO   ÚquiverÎ	  sX    +

ÿ


"

4zAxes3D.quiver©r™  r¤  rœ  r  c          1   	      s¢  t |ƒdkrdd„ }ndd„ }|||Ž\}‰}ˆjdkr@tdƒ‚tjˆjtjd}	t|	d ƒ‰ |dkrxt ˆ ¡\}
}}n‡ fd	d
„|D ƒ\}
}}‡fdd„}|dkr®| j	 
¡ }||dƒ}||dƒ}|  |
||¡ tjdddgdddgdddgdddggtjd}ttƒ}dd„ }|dƒD ]Œ}|j |	¡\}}}t |¡}t |¡}t |¡}| |j¡}|ddd… }|D ]4}|D ]&}| ||dg¡}t|ƒ}ˆ| r°||  || ¡ t|dd… |dd… ƒD ]ˆ\}}| |||g¡} | |||g¡}!t| ƒ}"t|!ƒ}#ˆ|" r*ˆ|# s*||"  |!| ¡ n&ˆ|" sÊˆ|# rÊ||#  |!| ¡ qÊ| |||d g¡}$| |||g¡}%t|$ƒ}&ˆ|& rv||&  |%| ¡ qvqlqi }'| ¡ D ]è\}(})|dkrÌ|)}*ng }*|)D ]†}+|+dd…df |+dd…df |+dd…df f},t |+j¡}-|
|, |-dd…df< ||, |-dd…df< ||, |-dd…df< |* |-¡ qÔ||( }.||( }/tj|*f|.|/||dœ|—Ž}0|  |0¡ |0|'|(< q´|'S )a‰
  
        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`
            The lightsource to use when *shade* is True.

        **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
        rs   c                 [   s   | ||f||fS r_   rN   )Z
_Axes3D__xZ
_Axes3D__yZ
_Axes3D__zr  rK   rN   rN   rO   Úvoxels¦
  s    zAxes3D.voxels.<locals>.voxelsc                 [   s
   d | |fS r_   rN   )r  rK   rN   rN   rO   r@  ©
  s    z%Argument filled must be 3-dimensionalrŸ   r   Nc                 3   s   | ]}t  |ˆ ¡V  qd S r_   )rŒ   rˆ  )r²   rÿ  )Úcoord_shaperN   rO   r´   ¸
  s     z Axes3D.voxels.<locals>.<genexpr>c                    sp   t  | ¡dkr&t  | ˆ jt  | ¡ ¡S t  | ¡dkr^t  | ¡d d… ˆ jkrZtd |¡ƒ‚| S td |¡ƒ‚d S )N)r   r   )rs   rt   rs   z8When multidimensional, {} must match the shape of filledzInvalid {} argument)rŒ   r¦  rˆ  rÛ   r    Úformat)rš  Úname)r  rN   rO   Ú_broadcast_color_argº
  s    ÿÿz+Axes3D.voxels.<locals>._broadcast_color_argr™  r¤  r   c                 s   s8   t j| t jd}t| ƒD ]}|V  t j|ddd}qdS )z%Generate cyclic permutation matrices.rŸ   r   r   r…   N)rŒ   r  Úintpr±  r   )ÚnÚmatrœ   rN   rN   rO   Úpermutation_matricesÝ
  s    z+Axes3D.voxels.<locals>.permutation_matricesr`  rr   r?  )rÍ   r¦  r    rŒ   r   rÛ   rE  rû   Úindicesr  r«  râ   r   r°  r]  r  Úaranger³  r²  Úitemsr  r   r¸  rÞ  )1rI   r™  r¤  rœ  r  rJ   rK   r@  ZxyzrÏ  r   r   r   rD  ZsquareZvoxel_facesrH  ZpermuteZpcZqcÚrcZpindsZqindsZrindsZsquare_rot_posZsquare_rot_negr^  Úqr  Zi0Zr1Zr2r  r  rã  rä  ÚpkZpk2ZikZpolygonsÚcoordZ
faces_indsZfacesZ	face_indsÚindÚfacer   Z	edgecolorZpolyrN   )rA  r  rO   r@  ]
  s¢    G




üû	





"

.ÿ  þþ
zAxes3D.voxelsÚxerrÚyerrÚzerrrE  c           C   	      s"  |   ¡ }t |tj¡}dd„ | ¡ D ƒ}| dd¡ | jd|fd|fd|fg|dd	 t 	|¡rd|n|g}t 	|¡rx|n|g}t 	|¡rŒ|n|g}t
|ƒt
|ƒ  kr²t
|ƒks¼n td
ƒ‚|  ||	¡‰| dd¡}d|d< | jj|dkrò||fn|||f|dd\\}}tj||d |r2| |d d ¡ n| |d d ¡ | ¡ dkr^|  |¡ nd}| d¡ d|kr~d|d< |
dkr|d }
dD ]}| |d¡ q”|d|
i–}|rÄ||d< nd|krÚ|d |d< dD ]}||krÞ|| ||< qÞ|ddi–}|dkrtjd }|dkr2d| |d< |dk	rD||d< |
|d< d d!„ }‡fd"d#„‰ g g g   }}}g } d$d$d%d&œ}!dd'dd(œ‰| dtjd) ¡d }"|"| jjd* 9 }"| j ¡  d+|"|"fg¡}"t tj|"dd,¡}"tj| dddd- tj  !|  "¡ ¡}#W 5 Q R X t #|#|"dddg¡d' }"|"d.9 }"||"d'd/œ–}$|$ dd¡ t$dddg|||g|||g|||g|||gƒD ]\}%}&‰‰‰t %|%¡‰ˆ|% }'ˆdkr¤qtt 	ˆ¡s¾ˆgt
|&ƒ ‰t &ˆ¡‰t 'ˆt
|&ƒ¡ (t)¡‰t 'ˆt
|&ƒ¡ (t)¡‰‡ ‡‡‡‡fd0d1„t*|||gƒD ƒ}(|(\\})}*\}+},\}-}.ˆˆB  }/|/ +¡ rÐ|dkrÐ||)|+|-g|/ˆ@ ƒ}0||*|,|.g|/ˆ@ ƒ}1tj,|0d|!|' d2œ|—Ž}2tj,|1d|!|' d2œ|—Ž}3|  |2¡ |  |3¡ | -|2¡ | -|3¡ ˆ +¡ r
||*|,|.gˆˆ@ ƒ\}4}5}6| j.|4|5|6fˆž|$Ž ˆ +¡ rF||)|+|-gˆˆ@ ƒ\}7}8}9| j.|7|8|9fˆ ž|$Ž tj/t 0|(¡j1f|Ž}:|  2|:¡ | -|:¡ |  -|(¡ qtt 0| ¡} ‡fd3d4„};|;| dƒ\}<}=|;| dƒ\}>}?|;| dƒ\}@}A|  3|<|=f|>|?f|@|Af|¡ t4j5|t6|ƒt6|ƒf|dk	pþ|dk	|dk	|d5}B| j7 -|B¡ |||fS )6a¼  
        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 : 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,
            `~.Axes.set_xlim` or `~.Axes.set_ylim` 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.

        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
        c                 S   s   i | ]\}}|d k	r||“qS r_   rN   )r²   r2  r  rN   rN   rO   Ú
<dictcomp>  s       z#Axes3D.errorbar.<locals>.<dictcomp>r¿   rr   r   r   r   F)Úconvertz)'x', 'y', and 'z' must have the same sizert  NÚ
_nolegend_rE  T)Zreturn_kwargs)rR  gš™™™™™¹?Únonerš  ZC0)ÚmarkerÚ
markersizeZmarkerfacecolorÚmarkeredgewidthZmarkeredgecolorZ	markeveryÚ	linestyleZ	fillstyleZ	drawstyleZdash_capstyleZdash_joinstyleZsolid_capstyleZsolid_joinstyleZ	linewidth)rF   r  r¿   Z
rasterizedr\  ÚNonezerrorbar.capsizer   r‡   rZ  r[  c                    s   ‡ fdd„| D ƒS )Nc                    s   g | ]}t  |ˆ ¡•‘qS rN   )r¶  Úcompress)r²   r   r3  rN   rO   rŸ  í  s     z8Axes3D.errorbar.<locals>._apply_mask.<locals>.<listcomp>rN   )Zarraysrö  rN   r3  rO   Ú_apply_maskê  s    z$Axes3D.errorbar.<locals>._apply_maskc                    sZ   t | jƒdkr| \}}n
| |  }}t |ˆ  B ||| ¡}t |ˆ  B ||| ¡}||fS r¥  )rÍ   rÛ   rŒ   r)  )ÚerrÚdataZlomaskZhimaskZlow_errZhigh_errZlowsZhighs)Ú	everymaskrN   rO   Ú_extract_errsï  s    

z&Axes3D.errorbar.<locals>._extract_errsú|Ú_)r   r   rr   r   r   zlines.markersizeéH   r%   r…   )r   r   r   gV&,t=Ûý?)r$  r%  c                    s&   g | ]\}}ˆ ˆˆ|  |ˆˆƒ‘qS rN   rN   )r²   rœ   rO  )rc  Ú
dir_vectorr`  ÚlolimsÚuplimsrN   rO   rŸ  8  s   ÿz#Axes3D.errorbar.<locals>.<listcomp>)ZlsrY  c              	      sL   t  | d d …ˆ | d d …d d …f ¡t  | d d …ˆ | d d …d d …f ¡fS r_   rø  )Zerr_arrZcoord_label)Úi_xyzrN   rO   Ú_digout_minmax_  s    $$ÿz'Axes3D.errorbar.<locals>._digout_minmax)Zhas_xerrZhas_yerrrt  )8r†  r   Znormalize_kwargsrå   ræ   rK  Ú
setdefaultZ_process_unit_inforŒ   r÷   rÍ   r    Z_errorevery_to_maskr4   rª  Z
_plot_argsr   rŠ  Z
set_zorderr  Zadd_liner.  r/  r®  r=   ZdpiZ	transAxesrE   rF   r   rî  Z_setattr_cmr—   Úinvrº   r  r²  Zget_dir_vectorr  rˆ  r8  rÔ   r’   rµ  ZLine3Dr³  r>  rÐ  r   r]  r¼  râ   Ú
mcontainerZErrorbarContainerrû   Z
containers)CrI   r   r   r   rT  rS  rR  ÚfmtZ	barsaboveZ
erroreveryZecolorZ
elinewidthZcapsizeZcapthickZxlolimsZxuplimsZylolimsZyuplimsZzlolimsZzuplimsrK   rá   rt  Z	data_lineZ
base_styler¶   Zeb_lines_styleZeb_cap_styler_  ZerrlinesZcaplinesZlimmarksZ	coorderrsZ	capmarkerZ
quiversizeZinvMZeb_quiver_stylerƒ  ra  Zi_zdirZcoorderrrÌ  ÚxhrÍ  ZyhrÎ  ÚzhZnolimsZlo_caps_xyzZhi_caps_xyzZcap_loZcap_hiZxh0Zyh0Zzh0Zxl0Zyl0Zzl0Zerrlinerk  rf   rg   rh   ri   rj   rk   Zerrorbar_containerrN   )rc  rg  r`  rb  rj  rh  ri  rO   Úerrorbar.  s   kÿ"  ÿ









ÿÿ
 ÿ ÿ   þ


þ
ÿþÿþ





ÿ


üzAxes3D.errorbar)Úfor_layout_onlyc          	         s^   t ƒ j||||d}|g}| jrR| j ¡ D ]&}| ¡ r*t ||¡}|r*| |¡ q*t	j
 |¡S )N)Úcall_axes_locatorÚbbox_extra_artistsrs  )r6   Úget_tightbboxrQ   r¼   r½   r±   ÚmartistZ_get_tightbbox_for_layout_onlyr³  r¦   r
   Úunion)	rI   rÀ   rt  ru  rs  r"  Úbatchr†   Zaxis_bbrL   rN   rO   rv  r  s     ý ÿzAxes3D.get_tightbboxzC0-ZC0ozC3-)ÚlinefmtÚ	markerfmtÚbasefmtrø   rt  Úorientationc                   sÄ  ddl m}
 |  ¡ }tjdddg|	d t |¡t |¡f}t |¡t |¡f}t |¡t |¡f}|	dkrœ|| }}|| }}‡ fdd„t|||ƒD ƒ}nf|	dkrÔ|| }}|| }}‡ fd	d„t|||ƒD ƒ}n.|| }}|| }}‡ fd
d„t|||ƒD ƒ}t	|ƒ\}}}|dkr$t
jd }| j|||ˆ |	dd\}tj|||dd}|  |¡ | j||||dd\}|
|||f|d}|  |¡ t ||ˆ ˆ g|	¡\}}}|  ||•||•||•|¡ |S )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, default: None
            The label to use for the stems in legends.

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

        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}  c                    s&   g | ]\}}}ˆ ||f|||fg‘qS rN   rN   ©r²   ZthisxZthisyZthisz©rø   rN   rO   rŸ  Ó  s   ÿzAxes3D.stem.<locals>.<listcomp>c                    s&   g | ]\}}}|ˆ |f|||fg‘qS rN   rN   r  r€  rN   rO   rŸ  Ø  s   ÿc                    s&   g | ]\}}}||ˆ f|||fg‘qS rN   rN   r  r€  rN   rO   rŸ  Ý  s   ÿNzlines.linestylerW  )rR  rƒ  rt  )Z
linestylesÚcolorsrt  )rt  )Úmatplotlib.containerr~  r†  r   rˆ   rŒ   rL  r   r²  r	   r.  r/  r‰  r   rÐ  r¼  Zadd_containerr‹  râ   )rI   r   r   r   rz  r{  r|  rø   rt  r}  r~  rá   r   r   r   ZbasexZbasexlimZbaseyZbaseylimrŒ  r\  Z
linemarkerZ	linecolorZbaselineZ	stemlinesZ
markerlineZstem_containerZjxÚjyZjzrN   r€  rO   Ústem‚  s^    B



ÿ



ÿ



ÿ

 ÿ   ÿ

ÿ
ÿ
zAxes3D.stem)N)N)N)NN)NN)NN)NN)NNF)N)TrÒ   N)NN)NTTT)NNTF)NNNr   )N)r   rr   rs   )re  NFF)NN)T)rÒ   )NN)N)ru   )Fru   r   N)r   N)r   N)r   r   )r   r   r  NT)r   r   )Nr  TN)Nr  )NNNrE  Fr   NNNNFFFFFF)NTN)”Ú__name__Ú
__module__Ú__qualname__Ú__doc__rC  Z_axis_namesr   ZGrouperr   r1   r   Zdeprecate_privatize_attributeÚdistr  r  ZsxZsyr7   r8   r9   rU   rC   r[   r]   r   Zget_zgridlinesZget_zticklinesÚ
deprecatedÚpropertyZw_xaxisZw_yaxisZw_zaxisrd   rb   ro   rm   rq   rp   r‰   r‹   r™   r«   rw  Zallow_rasterizationr¸   rÂ   rÃ   rØ   r×   rÇ   rÑ   rÚ   râ   rÐ   re   Zmake_keyword_onlyrú   r)  Zset_xlimr“   Zset_ylimr”   r•   rü   rý   rþ   Z
get_zscaleZ
set_xscaleZ
set_yscaleZ
set_zscaleÚmaprB  Z
get_zticksZ
set_zticksZget_zmajorticklabelsZget_zminorticklabelsZget_zticklabelsZset_zticklabelsZ
zaxis_dateÚtextwrapÚdedentrÿ   r/   r)   r  rº   r<   r%  r&  r'  r   r-  rA   rB   r>  rA  rD  rS  r@   rV  r  rm  rh  rX  rs  ru  rv  rx  r0  ry  r|  r~  r}  rè   r  Ztext3DZtext2Dr‰  Zplot3DrÅ  rÒ  rØ  rå  ré  rì  rë  r   rò  Z	contour3Dr÷  rú  rû  Z
contourf3Drü  rÞ  r	  Z	scatter3Dr  r  r   r>  Zquiver3Dr@  rr  rv  r„  Zstem3DÚ__classcell__rN   rN   rL   rO   r   *   sÖ  	




ÿ      ýt


ÿ
ÿ
ÿU&7

$# ÿ
>
 ÿ



ò




 þ
FC	(=$     ÿ
0&	

) ÿ Dvÿa0      ÿ
   ÿ%   ÿ4
0!
   þG6     ÿ !   ÿ ÿ R                     ý  E ÿÿ  ÿtr   r  c                 C   s°   t  dd| ¡ }}t  ||¡\}}t  |d |d   d ¡dt j  }t  |d d d |d d d   d ¡dt j d d  }|| }|d }|d }|d }|||fS )	z,Return a tuple X, Y, Z with a test data set.g      Àg      @rr   r   g      ø?r  r   iô  )rŒ   rJ  ZmeshgridÚexprc  )rë   r   r   rÞ   rß   ZZ1ZZ2rà   rN   rN   rO   Úget_test_dataú  s    &*ÿr‘  )r  )8rˆ  rÚ  r   r5  r¶  r+  r  ZnumpyrŒ   Z
matplotlibr.  r   r   r   r   Zmatplotlib.artistr³   rw  Zmatplotlib.axesZaxesr)  Zmatplotlib.collectionsr­   Zmatplotlib.colorsr  r¬  Zmatplotlib.imageÚimagerä   Zmatplotlib.linesrŒ  rå   Zmatplotlib.patchesr
  r¯   r‚  Ú	containerrn  Zmatplotlib.transformsZ
transformsr¦   r   Zmatplotlib.axes._baser   r	   r
   Zmatplotlib.tri._triangulationr   rE  r   r   r   ZinterpdZdefine_aliasesr   r‘  rN   rN   rN   rO   Ú<module>   sr     ÿ                         f