我正在尝试用plot的'lines+markers‘模式绘制时间序列图虽然我用一些列成功地绘制了线条和标记,但对于一些列,我不能成功绘制,并且在这几列上,只有’标记‘模式有效,但是所有这些列的数据类型都是float64。
下面是正在使用的代码片段
trace = go.Scatter(x=df.index, y=df['some_column'], mode='lines+markers', name='some_column',line=dict(width=0.5,color='red'),marker=dict(size=2, opacity=0.5),showlegend=False)
fig = py.tools.make_subplots(rows=1, cols=1)
fig.append_trace(trace, 1, 1) fig['layout'].update(title = 'some title' ) ;
py.offline.plot(fig, filename=strFilename + str(v) + '.html')我发现那些列中有缺失值,在这些列中'lines+markers‘没有任何解决方案来处理丢失的数据?
发布于 2019-04-23 12:22:31
我从https://community.plot.ly/t/missing-line-in-mode-lines/11429/4那里找到了答案,显然是因为我必须使用connectgaps=True的缺失间隙
所以代码应该是这样的
trace = go.Scatter(x=df.index, y=df['some_column'], mode='lines+markers', connectgaps= True,name='some_column',line=dict(width=0.5,color='red'),marker=dict(size=2, opacity=0.5),showlegend=False)
fig = py.tools.make_subplots(rows=1, cols=1)
fig.append_trace(trace, 1, 1) fig['layout'].update(title = 'some title' ) ;
py.offline.plot(fig, filename=strFilename + str(v) + '.html')感谢您的关注
https://stackoverflow.com/questions/55804159
复制相似问题