TypeError: scatter() missing 1 required positional argument: 'data_frame' in Plotly

Viewed 1661

I am a noob and was using the first example of Plotly Scatter plots.

import plotly.express as px
fig = px.scatter(x=[0, 1, 2, 3, 4], y=[0, 1, 4, 9, 16])
fig.show()

Error I got

TypeError: scatter() missing 1 required positional argument: 'data_frame'.

What I tried

fig = px.scatter(data_frame=None,x=[0, 1, 2, 3, 4], y=[0, 1, 4, 9, 16])

This does not solves my problem. Kindly help

Thank You

1 Answers

The plotly.express module is specifically there to make plotting columns of dataframes easily. As you do not have a dataframe, you shoudl use the 'non-express' (terminology mine) plotly. Try this

import plotly.graph_objects as go
fig = go.Figure()
fig = fig.add_trace(go.Scatter(x=[0, 1, 2, 3, 4], y=[0, 1, 4, 9, 16]))
fig.show()

output

plotly plot

Related