无法绘制阴影线

时间:2018-12-09 18:37:19

标签: python plotly

我正在尝试绘制类似于此link

中的最后图表的图表

我想要的是对中线(虚线)周围的区域进行阴影处理。因此,我计算了标准偏差并绘制了两条分离的线(上方和下方)。

enter image description here

当我尝试使用链接示例中的相同代码时,它会在我的图表中绘制一个大矩形: enter image description here 经过一些测试,我注意到如果删除fill='tozerox', fillcolor='rgb(0,176,246)'参数,它将在图表的末尾绘制一条大的垂直线: enter image description here

现在这是我的代码。请注意,由于我可以分别绘制线(注释线= chart1),所以我认为这是一个合理的假设,即这不是数据问题

def plot_chart(ratio, mean, time, up_close, low_close):
    time_rev = time[::-1]
    low_close = low_close[::-1]

    plotly.offline.plot({
        "data": [
        go.Scatter(x=time, y=list(reversed(ratio[:len(sma)])), name='Ratio', line=dict(color='rgb(0, 0, 0)')),
        go.Scatter(x=time, y=mean, name='Mean',line=dict(color='rgb(0, 0, 255)', dash='dot')),
 #This causes a rectangle (CHART 2):
        go.Scatter(x=time+time_rev, y=up_close+low_close, fill='tozerox', fillcolor='rgb(0,176,246)', name='Close Area',line=dict(color='rgb(255,255,255,0)')),

 #This plots the lines separately with no problem (CHART 1)
 #        go.Scatter(x=time, y=up_close, name='Close Area (Upper)',line=dict(color='rgb(0,176,246,0.2)')),
 #      go.Scatter(x=time_rev, y=low_close, name='Close Area (Lower)',line=dict(color='rgb(0,176,246,0.2)'))

 #This plots the vertical line at the end of the chart (CHART 3)
 #        go.Scatter(x=time+time_rev, y=up_close+low_close, name='Close Area',line=dict(color='rgb(0,176,246,0.2)')),

        ], "layout": go.Layout(title='Test with Mean + STD')
        }, auto_open=True)

我是plotly(和绘图库)的新手,所以我可能很简单。有人可以照亮吗?

谢谢。

0 个答案:

没有答案
相关问题