To_plotly_json method

Hi,

I’m using this little snippet:

import plotly.express as px
df = px.data.iris()
fig = px.scatter_3d(df, x='sepal_length', y='sepal_width', z='petal_width',
              color='species')

to create a plot. But now I want to insert that into a webpage using js, so I used fig.to_plotly_json.
However, when I paste that javascript dictionary into JS, (so I can render it using Plotly.newPlot('graph', data);I keep getting errors indicating that the to_plotly_json method is not actually javascript code. What gives? Can anyone point me in the right direction? thank you!

I didn’t check, but the method returns a py dict, not a json string as I assumed. They happen to look nearly identical! Used json module to convert. Sorry about that.