scatter3d#
- scatter3d(x=None, y=None, z=None, c='z', fig=True, ax=None, returnfig=False, figkwargs=None, axkwargs=None, **kwargs)[source]#
Plot 3D data as a scatter
Typically,
x
,y
, andz
, are all vectors. However, if a single 2D array is provided, then this will be treated asz
values andx
andy
will be inferred on a grid (or they can be provided explicitly).- Parameters:
x (arr) – 1D or 2D x coordinate data (or z-coordinate data if 2D and
z
isNone
)y (arr) – 1D or 2D y coordinate data
z (arr) – 1D or 2D z coordinate data
c (arr) – color data; defaults to match z; to use default colors, explicitly pass
c=None
; to use index, use c=’index’fig (fig) – an existing figure to draw the plot in (or set to True to create a new figure)
ax (axes) – an existing axes to draw the plot in
returnfig (bool) – whether to return the figure, or just the axes
figkwargs (dict) – passed to
plt.figure()
axkwargs (dict) – passed to
plt.axes()
kwargs (dict) – passed to
plt.scatter()
Examples:
# Implicit coordinates, color by height (z-value) data = np.random.randn(10, 10) sc.scatter3d(data) # Explicit coordinates, color by index (i.e. ordering) x,y,z = np.random.rand(3,50) sc.scatter3d(x, y, z, c='index')
New in version 3.0.0: Allow 2D inputNew in version 3.1.0: Allow “index” color argument; removed “plotkwargs” argument; “fig” defaults to True