class scatter3d(x, y=None, z=None, c='z', fig=None, ax=None, returnfig=False, figkwargs=None, axkwargs=None, plotkwargs=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.

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

  • y (arr) – y coordinate data

  • z (arr) – z coordinate data

  • c (arr) – color data; defaults to match z, explicitly pass c=None to use default colors

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

  • axkwargs (dict) – passed to axes()

  • plotkwargs (dict) – passed to plot()

  • kwargs (dict) – also passed to plot()


# Explicit coordinates
x,y,z = np.random.rand(3,50)
sc.scatter3d(x, y, z)

# Implicit coordinates
data = np.random.randn(10, 10)

New in version 3.0.0: allow 2D input.