小编gbo*_*oge的帖子

Plotly:如何向折线图添加水平线?

我用下面的代码制作了一个折线图,我试图在 y=1 处添加一条水平线。我尝试按照 plotly 站点上的说明进行操作,但仍未显示。有谁知道为什么?

date = can_tot_df.date
growth_factor = can_tot_df.growth_factor

trace0 = go.Scatter(
            x=date,
            y=growth_factor,
            mode = 'lines',
            name = 'growth_factor'
)

fig = go.Figure()
fig.add_shape(
        type='line',
        x0=date.min(),
        y0=1,
        x1=date.max(),
        y1=1,
        line=dict(
            color='Red',
        )
)


data = [trace0]
iplot(data)
Run Code Online (Sandbox Code Playgroud)

python plotly plotly-python

6
推荐指数
3
解决办法
1万
查看次数

标签 统计

plotly ×1

plotly-python ×1

python ×1