@@ -3288,6 +3288,98 @@ def get_tightbbox(self, renderer, call_axes_locator=True,
32883288 batch .append (axis_bb )
32893289 return mtransforms .Bbox .union (batch )
32903290
3291+ def stem (self , * args , ** kwargs ):
3292+ """
3293+ Create a 3D stem plot.
3294+
3295+ Call signatures::
3296+ stem3(x, y, z, linefmt='b-', markerfmt='bo', basefmt='r-',
3297+ zdir={'x'|'y'|'z'|'-x'|'-y'})
3298+
3299+ By default, stem plots vertical lines (using *linefmt*) in the z
3300+ direction at each *x* and *y* location from the baseline to *z*, and
3301+ places a marker there using *markerfmt*. By default, the baseline at
3302+ the xy-plane is plotted using *basefmt*.
3303+
3304+ *x*, *y, and *z* values are required and must be arrays of the same
3305+ length.
3306+
3307+ If no zdir value is provided, then it is set to default and no rotation
3308+ occurs.
3309+
3310+ Return value is a tuple (*markerline*, *stemlines*, *baseline*).
3311+
3312+ .. seealso::
3313+ This `document
3314+ <http://www.mathworks.com/help/techdoc/ref/stem3.html>`_ for
3315+ details.
3316+
3317+ **Example:**
3318+ .. plot:: /mplot3d/stem3d_demo.py
3319+ """
3320+
3321+ from matplotlib .container import StemContainer
3322+
3323+ had_data = self .has_data ()
3324+
3325+ # Extract the required values
3326+ x , y , z = [np .asarray (i ) for i in args [:3 ]]
3327+ args = args [3 :]
3328+
3329+ # Popping some defaults
3330+ try :
3331+ linefmt = kwargs .pop ('linefmt' , args [0 ])
3332+ except IndexError :
3333+ linefmt = kwargs .pop ('linefmt' , 'b-' )
3334+ try :
3335+ markerfmt = kwargs .pop ('markerfmt' , args [1 ])
3336+ except IndexError :
3337+ markerfmt = kwargs .pop ('markerfmt' , 'bo' )
3338+ try :
3339+ basefmt = kwargs .pop ('basefmt' , args [2 ])
3340+ except IndexError :
3341+ basefmt = kwargs .pop ('basefmt' , 'r-' )
3342+ try :
3343+ zdir = kwargs .pop ('zdir' , args [3 ])
3344+ except IndexError :
3345+ zdir = kwargs .pop ('zdir' , 'z' )
3346+
3347+ bottom = kwargs .pop ('bottom' , None )
3348+ label = kwargs .pop ('label' , None )
3349+
3350+ if bottom is None :
3351+ bottom = 0
3352+
3353+ stemlines = []
3354+ jx , jy , jz = art3d .juggle_axes (x , y , z , zdir )
3355+
3356+ # plot the baseline in the appropriate plane
3357+ for i in range (len (x )- 1 ):
3358+ baseline , = Axes .plot (self , [x [i ], x [i + 1 ]], [y [i ], y [i + 1 ]],
3359+ basefmt , label = "_nolegend_" )
3360+ art3d .line_2d_to_3d (baseline , [bottom , bottom ], zdir )
3361+
3362+ # plot the stemlines based on the value of rotate
3363+ for thisx , thisy , thisz in zip (x , y , z ):
3364+ l , = Axes .plot (self , [thisx , thisx ], [thisy , thisy ], linefmt ,
3365+ label = "_nolegend_" )
3366+ art3d .line_2d_to_3d (l , [bottom , thisz ], zdir )
3367+
3368+ stemlines .append (l )
3369+
3370+ markerline , = Axes .plot (self , x , y , markerfmt , label = "_nolegend_" )
3371+ art3d .line_2d_to_3d (markerline , z , zdir )
3372+
3373+ stem_container = StemContainer ((markerline , stemlines , baseline ),
3374+ label = label )
3375+ self .add_container (stem_container )
3376+
3377+ self .auto_scale_xyz (jx , jy , jz , had_data )
3378+
3379+ return stem_container
3380+
3381+ stem3D = stem
3382+
32913383docstring .interpd .update (Axes3D_kwdoc = artist .kwdoc (Axes3D ))
32923384docstring .dedent_interpd (Axes3D .__init__ )
32933385
0 commit comments