Iplot won't render line chart data

Attempting to do a line chart using fig to get axis labels. It renders the figure part but not the data (lines or markers). How can I get the data to display…

Python code follows:

Construct the figure

Data for the figure

x0 = X_train[range(0,1700)]
x1 = X_train[range(1,1700)]
trace0 = go.Scatter(x=x0,y=z,mode=‘lines’,name=“x=X[0,]”)
trace1 = go.Scatter(x=x1,y=z,mode=‘markers’,name=“x=X[1,]”)
data = [trace0,trace1]

Layout for the figure

title=“predictions from neural network”
xaxis_template = dict(title = “neural network estimates”)
yaxis_template = dict(title = “predicted results”)
layout = dict(title = title, xaxis = xaxis_template, yaxis = yaxis_template)

Assemble the figure

fig=dict(data=data, layout = layout)

Plot the figure

link_text=“Export to plot.ly”,

Hi @frogfanitw2,

I don’t see any obvious problems with your code. Could you post an updated example that includes some sample example data for x0, x1, and z and a screenshot of the result you’re seeing? And it would also be helpful if you could put the code in a fenced code block (https://help.github.com/articles/creating-and-highlighting-code-blocks/) so that the markdown renderer doesn’t mess up the formatting (this way it’s possible to copy and paste the code and try it out). Thanks!


It turns out the data x0, x1 were assigned incorrectly. Once I fixed that, the plot worked!

1 Like

Hello, I’ve had the issue others have with Plotly rendering graphs a few times, recently I’ve noticed when I stopped the kernel in Jupyter Notebooks the traceback had “constructor=go.Scatter”, but my code is for a line graph. When I changed “line” to “scatter” in my code it rendered properly as a scatter.

My code for a line graph and the resulting Traceback:
fig = px.line(bb, x=‘eventTime’, y=‘user’, color=‘company_id’, labels={‘y’:’#users’})

-> 214 return make_figure(args=locals(), constructor=go.Scatter)