bar3d#

bar3d(x=None, y=None, z=None, c='z', dx=0.8, dy=0.8, dz=None, fig=True, ax=None, returnfig=False, figkwargs=None, axkwargs=None, **kwargs)[source]#

Plot 2D data as 3D bars

Parameters:
  • x (arr) – 1D or 2D array of x coordinates (or z-coordinate data if 2D and z is None)

  • y (arr) – 1D or 2D array of y coordinates (optional)

  • z (arr) – 2D array of z coordinates; interpreted as the heights of the bars unless dz is also provided

  • c (arr) – color data; defaults to match z

  • dx (float/arr) – width of the bars

  • dy (float/arr) – depth of the bars

  • dz (float/arr) – height of the bars, in which case z is interpreted as the base of the bars

  • 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

  • colorbar (bool) – whether to plot a colorbar (true by default unless color data is provided)

  • figkwargs (dict) – passed to pl.figure()

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

  • kwargs (dict) – passed to ax.bar3d()

Examples:

# Simple example
data = pl.rand(5,4)
sc.bar3d(data)

# Use non-default axes and colors (note: this one is pretty!)
nx = 5
ny = 6
x = 10*np.arange(nx)
y = np.arange(ny) + 10
z = -pl.rand(ny,nx)
dz = -2*z
c = z**2
sc.bar3d(x=x, y=y, z=z, dx=0.5, dy=0.5, dz=dz, c=c, cmap='orangeblue')

New in 3.1.0: updated arguments from “data” to x, y, z, c; removed “plotkwargs” argument; “fig” defaults to True