✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

Tuple needed for a trace?

Hello all! Thank you for looking at this. I tried to do a trace with the random numbers I had generated into variables. Here is the code:
(BTW, go = plotly.graph_objects and nm = numpy)

def trace(self, go, nm):
	trace = go.Scatter3d(
		x = self.x_move,
		y = self.y_move,
		z = self.z_move,
		marker = dict(
			color= 'aqua',
			size = 2,
			opacity = 0.6	
		)
	)
	data.append(trace)

I get this error:

Traceback (most recent call last):
File “dash_walk.py”, line 126, in
walking(go, nm).whole_thing(go, nm, dash, dcc, html)
File “dash_walk.py”, line 122, in whole_thing
self.trace(go, nm)
File “dash_walk.py”, line 50, in trace
opacity = 0.6
File “/home/marc/.local/lib/python3.7/site-packages/plotly/graph_objs/init.py”, line 34822, in init
self[“x”] = x if x is not None else _v
File “/home/marc/.local/lib/python3.7/site-packages/plotly/basedatatypes.py”, line 3490, in setitem
self._set_prop(prop, value)
File “/home/marc/.local/lib/python3.7/site-packages/plotly/basedatatypes.py”, line 3777, in _set_prop
raise err
File “/home/marc/.local/lib/python3.7/site-packages/plotly/basedatatypes.py”, line 3772, in _set_prop
val = validator.validate_coerce(val)
File “/home/marc/.local/lib/python3.7/site-packages/_plotly_utils/basevalidators.py”, line 389, in validate_coerce
self.raise_invalid_val(v)
File “/home/marc/.local/lib/python3.7/site-packages/_plotly_utils/basevalidators.py”, line 283, in raise_invalid_val
valid_clr_desc=self.description(),
ValueError:
Invalid value of type ‘builtins.int’ received for the ‘x’ property of scatter3d
Received value: -3

The 'x' property is an array that may be specified as a tuple,
list, numpy array, or pandas Series

I am a bit new to this, so I wasn’t sure why this dictionary needed a tuple. I tried it setting the values to a tuple and that didn’t work. Any help is appreciated. Thank you!

It looks like the x property indeed received an int -3 instead of a sequence. Scatter plots expect sequences since they can plot multiple points.
Try to cast your x/y/z_moves to sequence structures (ex: your int -3 to a tuple (-3,))

Thank you so much! Making it a tuple did work. On to the next mistake!