【发布时间】:2019-07-20 14:01:04
【问题描述】:
我们如何通过 plotly 的 go.Layout 为数据框数据集指定虚线与虚线?下面是我的代码,它使用数据框并用实线吐出一个图。
我想使用第二个数据框对象在同一个图中使用虚线。
从某种意义上说,我正在尝试比较两个具有相同确切列名但它们需要具有不同的行格式以便于比较的数据帧。
附: help(go.Layout) 仅包含有关spikedlines 的信息,但没有关于通常的行格式的信息。
非常感谢,
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`
plot_df = [{
'x': df1.index,
'y': df1[col],
'name': col
} for col in df1.columns]
layout= go.Layout(
title= 'Plot_with_solidline',
xaxis= dict(title= 'Iteration'),
yaxis=dict(title= 'Accuracy'),
showlegend= True
)
fig= go.Figure(data=plot_df, layout=layout)
plot(fig, filename='pandas-line-naming-traces', auto_open=False)
【问题讨论】:
标签: python pandas plot jupyter-notebook plotly