Scatter3d
Overview
The scatter3d
trace type is used to create 3D scatter plots, which visualize data points based on three numerical variables (x, y, and z axes). 3D scatter plots are useful for exploring relationships between three variables and detecting patterns or outliers in higher-dimensional data.
You can customize the marker size, color, and add lines to connect points in 3D space to represent the data effectively.
Common Uses
- 3D Relationship Analysis: Exploring the relationship between three numerical variables.
- Pattern Detection: Identifying trends and clusters in three dimensions.
- High-Dimensional Data: Visualizing higher-dimensional datasets.
Check out the Attributes for the full set of configuration options
Examples
Common Configurations
Here's a simple scatter3d
plot showing data points in 3D space:
You can copy this code below to create this chart in your project:
models:
- name: scatter3d-data
args:
- echo
- |
x,y,z
1,10,15
2,20,25
3,15,30
4,25,35
5,30,40
traces:
- name: Simple Scatter3D Plot
model: ${ref(scatter3d-data)}
props:
type: scatter3d
x: ?{x}
y: ?{y}
z: ?{z}
mode: "markers"
charts:
- name: Simple Scatter3D Chart
traces:
- ${ref(Simple Scatter3D Plot)}
layout:
title:
text: Simple Scatter3D Plot<br><sub>3D Data Points</sub>
This example demonstrates a scatter3d
plot with lines connecting the data points in 3D space:
Here's the code:
models:
- name: scatter3d-data-lines
args:
- echo
- |
x,y,z
1,5,7
2,10,12
3,8,10
4,15,18
5,12,17
traces:
- name: Scatter3D Plot with Lines
model: ${ref(scatter3d-data-lines)}
props:
type: scatter3d
x: ?{x}
y: ?{y}
z: ?{z}
mode: "lines+markers"
charts:
- name: Scatter3D Chart with Lines
traces:
- ${ref(Scatter3D Plot with Lines)}
layout:
title:
text: Scatter3D Plot with Lines<br><sub>Connecting Data Points with Lines</sub>
Here's a scatter3d
plot with custom marker sizes and colors, giving more visual weight to each data point in 3D space:
Here's the code:
models:
- name: scatter3d-data-custom
args:
- echo
- |
x,y,z,size,color
1,5,10,15,#1f77b4
2,10,12,20,#ff7f0e
3,8,10,25,#2ca02c
4,15,18,30,#d62728
5,12,20,35,#9467bd
traces:
- name: Scatter3D Plot with Custom Markers
model: ${ref(scatter3d-data-custom)}
props:
type: scatter3d
x: ?{x}
y: ?{y}
z: ?{z}
mode: "markers"
marker:
size: ?{size}
color: ?{color}
charts:
- name: Scatter3D Chart with Custom Markers
traces:
- ${ref(Scatter3D Plot with Custom Markers)}
layout:
title:
text: Scatter3D Plot with Custom Markers<br><sub>Custom Sizes and Colors for 3D Data Points</sub>
A schema to validate plotly trace properties
Attributes
These attributes apply to traces where trace.props.type
is set to scatter3d
. You would configure these attributes on the trace with the trace.props
object.
connectgaps: boolean
customdata: array
customdatasrc: 'string' #(1)!
error_x:
array: array
arrayminus: array
arrayminussrc: 'string' #(2)!
arraysrc: 'string' #(3)!
color: any
copy_zstyle: boolean
symmetric: boolean
thickness: number
traceref: integer
tracerefminus: integer
type: any
value: number
valueminus: number
visible: boolean
width: number
error_y:
array: array
arrayminus: array
arrayminussrc: 'string' #(4)!
arraysrc: 'string' #(5)!
color: any
copy_zstyle: boolean
symmetric: boolean
thickness: number
traceref: integer
tracerefminus: integer
type: any
value: number
valueminus: number
visible: boolean
width: number
error_z:
array: array
arrayminus: array
arrayminussrc: 'string' #(6)!
arraysrc: 'string' #(7)!
color: any
symmetric: boolean
thickness: number
traceref: integer
tracerefminus: integer
type: any
value: number
valueminus: number
visible: boolean
width: number
hoverinfo: array
hoverinfosrc: 'string' #(8)!
hoverlabel:
align: array
alignsrc: 'string' #(9)!
bgcolor: array
bgcolorsrc: 'string' #(10)!
bordercolor: array
bordercolorsrc: 'string' #(11)!
font:
color: array
colorsrc: 'string' #(12)!
family: 'string | array' #(13)!
familysrc: 'string' #(14)!
lineposition: array
linepositionsrc: 'string' #(15)!
shadow: 'string | array' #(16)!
shadowsrc: 'string' #(17)!
size: array
sizesrc: 'string' #(18)!
style: array
stylesrc: 'string' #(19)!
textcase: array
textcasesrc: 'string' #(20)!
variant: array
variantsrc: 'string' #(21)!
weight: array
weightsrc: 'string' #(22)!
namelength: array
namelengthsrc: 'string' #(23)!
hovertemplate: 'string | array' #(24)!
hovertemplatesrc: 'string' #(25)!
hovertext: 'string | array' #(26)!
hovertextsrc: 'string' #(27)!
ids: array
idssrc: 'string' #(28)!
legend: string
legendgroup: 'string' #(29)!
legendgrouptitle:
font:
color: any
family: 'string' #(30)!
lineposition: any
shadow: 'string' #(31)!
size: number
style: any
textcase: any
variant: any
weight: integer
text: 'string' #(32)!
legendrank: number
legendwidth: number
line:
autocolorscale: boolean
cauto: boolean
cmax: number
cmid: number
cmin: number
color: array
coloraxis: string
colorbar:
bgcolor: any
bordercolor: any
borderwidth: number
exponentformat: any
len: number
lenmode: any
minexponent: number
nticks: integer
orientation: any
outlinecolor: any
outlinewidth: number
separatethousands: boolean
showexponent: any
showticklabels: boolean
showtickprefix: any
showticksuffix: any
thickness: number
thicknessmode: any
tickangle: number
tickcolor: any
tickfont:
color: any
family: 'string' #(33)!
lineposition: any
shadow: 'string' #(34)!
size: number
style: any
textcase: any
variant: any
weight: integer
tickformat: 'string' #(35)!
tickformatstops: array
ticklabeloverflow: any
ticklabelposition: any
ticklabelstep: integer
ticklen: number
tickmode: any
tickprefix: 'string' #(36)!
ticks: any
ticksuffix: 'string' #(37)!
ticktext: array
ticktextsrc: 'string' #(38)!
tickvals: array
tickvalssrc: 'string' #(39)!
tickwidth: number
title:
font:
color: any
family: 'string' #(40)!
lineposition: any
shadow: 'string' #(41)!
size: number
style: any
textcase: any
variant: any
weight: integer
side: any
text: 'string' #(42)!
x: number
xanchor: any
xpad: number
xref: any
y: number
yanchor: any
ypad: number
yref: any
colorscale: any
colorsrc: 'string' #(43)!
dash: any
reversescale: boolean
showscale: boolean
width: number
marker:
autocolorscale: boolean
cauto: boolean
cmax: number
cmid: number
cmin: number
color: array
coloraxis: string
colorbar:
bgcolor: any
bordercolor: any
borderwidth: number
exponentformat: any
len: number
lenmode: any
minexponent: number
nticks: integer
orientation: any
outlinecolor: any
outlinewidth: number
separatethousands: boolean
showexponent: any
showticklabels: boolean
showtickprefix: any
showticksuffix: any
thickness: number
thicknessmode: any
tickangle: number
tickcolor: any
tickfont:
color: any
family: 'string' #(44)!
lineposition: any
shadow: 'string' #(45)!
size: number
style: any
textcase: any
variant: any
weight: integer
tickformat: 'string' #(46)!
tickformatstops: array
ticklabeloverflow: any
ticklabelposition: any
ticklabelstep: integer
ticklen: number
tickmode: any
tickprefix: 'string' #(47)!
ticks: any
ticksuffix: 'string' #(48)!
ticktext: array
ticktextsrc: 'string' #(49)!
tickvals: array
tickvalssrc: 'string' #(50)!
tickwidth: number
title:
font:
color: any
family: 'string' #(51)!
lineposition: any
shadow: 'string' #(52)!
size: number
style: any
textcase: any
variant: any
weight: integer
side: any
text: 'string' #(53)!
x: number
xanchor: any
xpad: number
xref: any
y: number
yanchor: any
ypad: number
yref: any
colorscale: any
colorsrc: 'string' #(54)!
line:
autocolorscale: boolean
cauto: boolean
cmax: number
cmid: number
cmin: number
color: array
coloraxis: string
colorscale: any
colorsrc: 'string' #(55)!
reversescale: boolean
width: number
opacity: number
reversescale: boolean
showscale: boolean
size: array
sizemin: number
sizemode: any
sizeref: number
sizesrc: 'string' #(56)!
symbol: array
symbolsrc: 'string' #(57)!
metasrc: 'string' #(58)!
mode: any
name: 'string' #(59)!
opacity: number
projection:
x:
opacity: number
scale: number
show: boolean
y:
opacity: number
scale: number
show: boolean
z:
opacity: number
scale: number
show: boolean
scene: string
showlegend: boolean
stream:
maxpoints: number
token: 'string' #(60)!
surfaceaxis: any
surfacecolor: any
text: 'string | array' #(61)!
textfont:
color: array
colorsrc: 'string' #(62)!
family: 'string | array' #(63)!
familysrc: 'string' #(64)!
size: array
sizesrc: 'string' #(65)!
style: array
stylesrc: 'string' #(66)!
variant: array
variantsrc: 'string' #(67)!
weight: array
weightsrc: 'string' #(68)!
textposition: array
textpositionsrc: 'string' #(69)!
textsrc: 'string' #(70)!
texttemplate: 'string | array' #(71)!
texttemplatesrc: 'string' #(72)!
type: scatter3d
uid: 'string' #(73)!
visible: any
x: array
xcalendar: any
xhoverformat: 'string' #(74)!
xsrc: 'string' #(75)!
y: array
ycalendar: any
yhoverformat: 'string' #(76)!
ysrc: 'string' #(77)!
z: array
zcalendar: any
zhoverformat: 'string' #(78)!
zsrc: 'string' #(79)!
- Sets the source reference on Chart Studio Cloud for
customdata
. - Sets the source reference on Chart Studio Cloud for
arrayminus
. - Sets the source reference on Chart Studio Cloud for
array
. - Sets the source reference on Chart Studio Cloud for
arrayminus
. - Sets the source reference on Chart Studio Cloud for
array
. - Sets the source reference on Chart Studio Cloud for
arrayminus
. - Sets the source reference on Chart Studio Cloud for
array
. - Sets the source reference on Chart Studio Cloud for
hoverinfo
. - Sets the source reference on Chart Studio Cloud for
align
. - Sets the source reference on Chart Studio Cloud for
bgcolor
. - Sets the source reference on Chart Studio Cloud for
bordercolor
. - Sets the source reference on Chart Studio Cloud for
color
. - HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available.
- Sets the source reference on Chart Studio Cloud for
family
. - Sets the source reference on Chart Studio Cloud for
lineposition
. - Sets the shape and color of the shadow behind text. auto places minimal shadow and applies contrast text font color. See https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow for additional options.
- Sets the source reference on Chart Studio Cloud for
shadow
. - Sets the source reference on Chart Studio Cloud for
size
. - Sets the source reference on Chart Studio Cloud for
style
. - Sets the source reference on Chart Studio Cloud for
textcase
. - Sets the source reference on Chart Studio Cloud for
variant
. - Sets the source reference on Chart Studio Cloud for
weight
. - Sets the source reference on Chart Studio Cloud for
namelength
. - Template string used for rendering the information that appear on hover box. Note that this will override
hoverinfo
. Variables are inserted using %{variable}, for example "y: %{y}" as well as %{xother}, {%xother}, {%_xother}, {%xother_}. When showing info for several points, xother will be added to those with different x positions from the first point. An underscore before or after (x|y)other will add a space on that side, only when this field is shown. Numbers are formatted using d3-format's syntax %{variable:d3-format}, for example "Price: %{y:$.2f}". https://github.com/d3/d3-format/tree/v1.4.5#d3-format for details on the formatting syntax. Dates are formatted using d3-time-format's syntax %{variable|d3-time-format}, for example "Day: %{2019-01-01|%A}". https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format for details on the date formatting syntax. The variables available inhovertemplate
are the ones emitted as event data described at this link https://plotly.com/javascript/plotlyjs-events/#event-data. Additionally, every attributes that can be specified per-point (the ones that arearrayOk: true
) are available. Anything contained in tag<extra>
is displayed in the secondary box, for example "{fullData.name} ". To hide the secondary box completely, use an empty tag<extra></extra>
. - Sets the source reference on Chart Studio Cloud for
hovertemplate
. - Sets text elements associated with each (x,y,z) triplet. If a single string, the same string appears over all the data points. If an array of string, the items are mapped in order to the this trace's (x,y,z) coordinates. To be seen, trace
hoverinfo
must contain a text flag. - Sets the source reference on Chart Studio Cloud for
hovertext
. - Sets the source reference on Chart Studio Cloud for
ids
. - Sets the legend group for this trace. Traces and shapes part of the same legend group hide/show at the same time when toggling legend items.
- HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available.
- Sets the shape and color of the shadow behind text. auto places minimal shadow and applies contrast text font color. See https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow for additional options.
- Sets the title of the legend group.
- HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available.
- Sets the shape and color of the shadow behind text. auto places minimal shadow and applies contrast text font color. See https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow for additional options.
- Sets the tick label formatting rule using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format. And for dates see: https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format. We add two items to d3's date formatter: %h for half of the year as a decimal number as well as %{n}f for fractional seconds with n digits. For example, 2016-10-13 09:15:23.456 with tickformat %H~%M~%S.%2f would display 09~15~23.46
- Sets a tick label prefix.
- Sets a tick label suffix.
- Sets the source reference on Chart Studio Cloud for
ticktext
. - Sets the source reference on Chart Studio Cloud for
tickvals
. - HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available.
- Sets the shape and color of the shadow behind text. auto places minimal shadow and applies contrast text font color. See https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow for additional options.
- Sets the title of the color bar.
- Sets the source reference on Chart Studio Cloud for
color
. - HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available.
- Sets the shape and color of the shadow behind text. auto places minimal shadow and applies contrast text font color. See https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow for additional options.
- Sets the tick label formatting rule using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format. And for dates see: https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format. We add two items to d3's date formatter: %h for half of the year as a decimal number as well as %{n}f for fractional seconds with n digits. For example, 2016-10-13 09:15:23.456 with tickformat %H~%M~%S.%2f would display 09~15~23.46
- Sets a tick label prefix.
- Sets a tick label suffix.
- Sets the source reference on Chart Studio Cloud for
ticktext
. - Sets the source reference on Chart Studio Cloud for
tickvals
. - HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available.
- Sets the shape and color of the shadow behind text. auto places minimal shadow and applies contrast text font color. See https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow for additional options.
- Sets the title of the color bar.
- Sets the source reference on Chart Studio Cloud for
color
. - Sets the source reference on Chart Studio Cloud for
color
. - Sets the source reference on Chart Studio Cloud for
size
. - Sets the source reference on Chart Studio Cloud for
symbol
. - Sets the source reference on Chart Studio Cloud for
meta
. - Sets the trace name. The trace name appears as the legend item and on hover.
- The stream id number links a data trace on a plot with a stream. See https://chart-studio.plotly.com/settings for more details.
- Sets text elements associated with each (x,y,z) triplet. If a single string, the same string appears over all the data points. If an array of string, the items are mapped in order to the this trace's (x,y,z) coordinates. If trace
hoverinfo
contains a text flag and hovertext is not set, these elements will be seen in the hover labels. - Sets the source reference on Chart Studio Cloud for
color
. - HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available.
- Sets the source reference on Chart Studio Cloud for
family
. - Sets the source reference on Chart Studio Cloud for
size
. - Sets the source reference on Chart Studio Cloud for
style
. - Sets the source reference on Chart Studio Cloud for
variant
. - Sets the source reference on Chart Studio Cloud for
weight
. - Sets the source reference on Chart Studio Cloud for
textposition
. - Sets the source reference on Chart Studio Cloud for
text
. - Template string used for rendering the information text that appear on points. Note that this will override
textinfo
. Variables are inserted using %{variable}, for example "y: %{y}". Numbers are formatted using d3-format's syntax %{variable:d3-format}, for example "Price: %{y:$.2f}". https://github.com/d3/d3-format/tree/v1.4.5#d3-format for details on the formatting syntax. Dates are formatted using d3-time-format's syntax %{variable|d3-time-format}, for example "Day: %{2019-01-01|%A}". https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format for details on the date formatting syntax. Every attributes that can be specified per-point (the ones that arearrayOk: true
) are available. - Sets the source reference on Chart Studio Cloud for
texttemplate
. - Assign an id to this trace, Use this to provide object constancy between traces during animations and transitions.
- Sets the hover text formatting rulefor
x
using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format. And for dates see: https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format. We add two items to d3's date formatter: %h for half of the year as a decimal number as well as %{n}f for fractional seconds with n digits. For example, 2016-10-13 09:15:23.456 with tickformat %H~%M~%S.%2f would display 09~15~23.46By default the values are formatted usingxaxis.hoverformat
. - Sets the source reference on Chart Studio Cloud for
x
. - Sets the hover text formatting rulefor
y
using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format. And for dates see: https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format. We add two items to d3's date formatter: %h for half of the year as a decimal number as well as %{n}f for fractional seconds with n digits. For example, 2016-10-13 09:15:23.456 with tickformat %H~%M~%S.%2f would display 09~15~23.46By default the values are formatted usingyaxis.hoverformat
. - Sets the source reference on Chart Studio Cloud for
y
. - Sets the hover text formatting rulefor
z
using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format. And for dates see: https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format. We add two items to d3's date formatter: %h for half of the year as a decimal number as well as %{n}f for fractional seconds with n digits. For example, 2016-10-13 09:15:23.456 with tickformat %H~%M~%S.%2f would display 09~15~23.46By default the values are formatted usingzaxis.hoverformat
. - Sets the source reference on Chart Studio Cloud for
z
.