Reputation: 353
I am new to Dash and trying to run the below code for a Scatter plot.The graph is coming but no data points in it.May I know where I went wrong
My Code
import numpy as np
import dash
import dash_html_components as html
import plotly.graph_objects as go
import dash_core_components as dcc
app = dash.Dash()
np.random.seed(42)
random_x = np.random.randint(1, 101, 100)
random_y = np.random.randint(1, 101, 100)
app.layout = html.Div(
[
dcc.Graph(
id="Scatter Plot",
figure={
"Data": [
go.Scatter(
x=random_x,
y=random_y,
mode="markers",
)
],
"layout": go.Layout(title="My Scatter Plot"),
},
)
]
)
if __name__ == "__main__":
app.run_server()
My Output
Upvotes: 0
Views: 881
Reputation: 1036
The correct dictionary key for a figure is "data"
rather than "Data"
:
fig = {
"data": [
go.Scatter(
x=random_x,
y=random_y,
mode="markers",
)
],
"layout": go.Layout(title="My Scatter Plot"),
}
Upvotes: 1