Scatter plot error

scatter plot

import numpy as np
import plotly.offline as pyo
import plotly.graph_objs as go

np.random.seed(42)
random_x= np.random.randint(1,101,100)
random_y= np.random.randint(1,101,100)

data=[go.Scatter(random_x,random_y, mode=‘markers’) ]

Console

data=[go.Scatter(random_x,random_y, mode=‘markers’) ]
Traceback (most recent call last):

File “”, line 1, in
data=[go.Scatter(random_x,random_y, mode=‘markers’) ]

**ValueError: The first argument to the plotly.graph_objs.Scatter **
**constructor must be a dict or **
an instance of plotly.graph_objs.Scatter

Can anyone help me to resolve this error

You have to specify x and y.
In your case you have yo write : data=[go.Scatter(x=random_x, y=random_y, mode=‘markers’) ]

1 Like