Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Plotly · Class

go.Volume

A Volume trace renders a scalar field as partially transparent 3-D isosurfaces. Supply x, y, z coordinates and a value for every vertex, then control bounds, opacity, slices, caps, and spaceframe rendering.

How it works

Volume constructs a 3-D volume trace from one-dimensional coordinate arrays and a scalar value for every grid vertex. It renders isosurfaces between selected minimum and maximum values, with optional transparency, slices, caps, and a spaceframe.

Syntax

plotly.graph_objects.Volume(arg=None, autocolorscale=None, caps=None, cauto=None, cmax=None, cmid=None, cmin=None, coloraxis=None, colorbar=None, colorscale=None, hoverinfo=None, hoverinfosrc=None, hoverlabel=None, hovertemplate=None, hovertext=None, ids=None, idssrc=None, isomax=None, isomin=None, isosurface=None, legend=None, meta=None, metasrc=None, name=None, opacity=None, opacityscale=None, reversescale=None, scene=None, showlegend=None, showscale=None, surface=None, surface_count=None, text=None, uid=None, uirevision=None, value=None, valuehoverformat=None, visible=None, x=None, xhoverformat=None, y=None, yhoverformat=None, z=None, zhoverformat=None, **kwargs)

Parameters

NameTypeDescription
argdict or plotly.graph_objects.VolumeDictionary of constructor-compatible properties or an existing Volume instance.
autocolorscaleboolWhether to use a default palette rather than the colorscale property.
slicesplotly.graph_objects.volume.Slices or dictConfiguration for horizontal or vertical slices.
capsplotly.graph_objects.volume.Caps or dictConfiguration for caps on the volume.
spaceframeplotly.graph_objects.volume.Spaceframe or dictConfiguration for the spaceframe.
textstr or array-likeText associated with vertices.
valuearray-likeScalar values assigned to vertices.
xarray-likeX coordinates of vertices.
yarray-likeY coordinates of vertices.
zarray-likeZ coordinates of vertices.
kwargsdictAdditional supported trace properties.

Returns

A plotly.graph_objects.Volume trace object.

Key points

  • The trace renders isosurfaces bounded by iso-min and iso-max values.
  • Input consists of one-dimensional arrays for x, y, z coordinates and the scalar value at each vertex.
  • The grid may be uniform or non-uniform.
  • Optional slices, caps, and a spaceframe can expose or outline parts of the volume.
  • value supplies the scalar field associated with the spatial vertices.
  • opacityscale can create depth cues by varying opacity across scalar values.

Common mistakes

  • The default surface count is only two, so increase surface_count when you want a more continuous volume appearance.
  • Custom opacity scales use relative opacity values from 0 to 1; the global opacity still limits the resulting transparency.

Example: Render a 3-D scalar field

import numpy as np
import plotly.graph_objects as go

x, y, z = np.mgrid[-1:1:15j, -1:1:15j, -1:1:15j]
value = np.exp(-(x**2 + y**2 + z**2))

fig = go.Figure(go.Volume(
    x=x.ravel(), y=y.ravel(), z=z.ravel(), value=value.ravel(),
    isomin=0.2, isomax=0.8, opacity=0.1, surface_count=12
))
fig.show()

Creates a runnable interactive volume rendering from a regular 3-D scalar field.

When to use it

Scientific volume rendering

Inspect a simulated or measured scalar field in three dimensions.

Isosurface analysis

Show internal thresholds or layers in a volumetric dataset.

Interactive slices

Reveal selected cross-sections through a 3-D field.

Caps and spaceframe context

Provide an outlined spatial context around rendered values.

Interview questions

QWhat does plotly.graph_objects.Volume represent?

Volume is a graph-object trace for rendering a scalar field in three dimensions. The coordinates and values are supplied as four one-dimensional arrays, and the trace draws isosurfaces between iso-min and iso-max.

Follow-up: How can depth perception be improved? Use opacityscale together with opacity so scalar values map to different transparency levels.

QWhat data does a Volume trace require?

The x, y, and z arrays provide vertex coordinates, while value provides the fourth, scalar dimension associated with each vertex. These arrays describe either a uniform or non-uniform 3-D grid.

Follow-up: What must be checked when preparing data? Ensure the coordinate and value arrays describe corresponding vertices and have compatible lengths.

QHow does surface_count affect rendering?

surface_count controls how many isosurfaces are drawn between the minimum and maximum iso-values. Its documented default is 2, which draws only the minimum and maximum surfaces.

Follow-up: How would you add internal views? Configure slices, caps, or the spaceframe properties on the trace.

  • plotly.graph_objects.Isosurface
  • plotly.graph_objects.volume.Caps
  • plotly.graph_objects.volume.Slices
  • plotly.graph_objects.volume.Spaceframe
  • plotly.graph_objects.volume.Surface

Source: plotly.graph_objects.Volume — 7.0.0 documentation. Checked 2026-10-15.