找出解决方案并回答可能会遇到此类错误的其他人。
添加需要在数据对象本身中完成。
init_notebook_mode(connected=True) import plotly.plotly as py import plotly.graph_objs as go import pandas as pd #sample dataframe defined into `df1`, `df2` layout=go.Layout( title= 'Plot_with_solidline_dashline', xaxis= dict(title= 'Iteration'), yaxis=dict(title= 'Accuracy'), showlegend= True ) plot_df=[] for col in df1.columns: plot_df.append( go.Scatter(x=df1.index, y=df1[col], mode='lines', line={'dash': 'solid'}, name=col) ) plot_df.append( go.Scatter(x=df2.index, y=df2[col], mode='lines', line={'dash': 'dash'}, name=col) ) fig= go.Figure(data=plot_df, layout=layout) plot(fig, filename='pandas-line-naming-traces', auto_open=False)