class 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, and z, are all vectors. However, if a single 2D array is provided, then this will be treated as z values and x and y will be inferred on a grid (or they can be provided explicitly).

  • x (arr) – 1D or 2D x coordinate data (or z-coordinate data if 2D and z is None)

  • 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 pl.figure()

  • axkwargs (dict) – passed to pl.axes()

  • kwargs (dict) – passed to pl.scatter()


# Implicit coordinates, color by height (z-value)
data = pl.randn(10, 10)

# Explicit coordinates, color by index (i.e. ordering)
x,y,z = pl.rand(3,50)
sc.scatter3d(x, y, z, c='index')
New in version 3.0.0: Allow 2D input
New in version 3.1.0: Allow “index” color argument; removed “plotkwargs” argument; “fig” defaults to True