Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! ✅Check out the new docs.

Nameerror while trying to use downloaded json to generate figure

I have some dummy data loaded onto the plotly webapp and have generated an example plotly scatter plot.

I am trying to use the Python API to generate my own figure offline with the downloaded styling as the code below:
import plotly.plotly as py from plotly.graph_objs import * { data:[ { name:"Col2", type:"scatter", mode:"markers", xsrc:"data_x", ysrc:"data_y", uid:"aeaa2d" } ], layout:{ yaxis:{ type:"linear", range:[ -3417.1283057844134, 44578.36774670238 ], autorange:true }, xaxis:{ type:"linear", range:[ -2889.858759304667, -2637.479619601583 ], autorange:true }, height:780, width:1044, autosize:true } } fig = Figure(data=data, layout=layout) plot_url = py.plot(fig)

I get the following error when I run it.
File "plotly_example.py", line 8, in <module> name:"Col2", NameError: name 'name' is not defined

Any help appreciated. I am using Plotly version 1.9.8 on an Ubuntu 64 bit machine.

Looks like you pasted and tried to run a non-python structure in python.

data = [
  dict(
    name:"Col2",
    type:"scatter",
    mode:"markers",
    xsrc:"data_x",
    ysrc:"data_y",
    uid:"aeaa2d"
  )
]

layout = dict(
  yaxis: dict(
    type:"linear",
    range:[
      -3417.1283057844134,
      44578.36774670238
    ],
    autorange:True
  )
  xaxis: dict(
    type:"linear",
    range: [
     -2889.858759304667,
     -2637.479619601583
    ],
    autorange:true
  )
  height:780,
  width:1044,
  autosize:true
)


fig = Figure(data=data, layout=layout)
plot_url = py.plot(fig)