gpt4 book ai didi

python - Plotly:如何填充线之间的区域?

转载 作者:行者123 更新时间:2023-12-03 23:53:39 24 4
gpt4 key购买 nike

我在构建地平线图时遇到困难 plotly .我成功地用 matplotlib.plotly 构建了这个使用来自 Implementing horizon charts in matplotlib 的演示代码,但失败 plotly因为我找不到任何函数来实现fill_betweenplotly .

我想知道如何填充 plotly 中两条虚线之间的区域.

最佳答案

只需使用 fill=tozeroy像这样:

剧情:

enter image description here

代码:

import plotly.graph_objects as go

fig = go.Figure()
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[0, 2, 3],
mode = 'lines',
fill='tozeroy'))
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[3, 5, 4],
mode = 'lines',
fill='tonexty'))
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[4, 5.5, 6],
mode = 'lines',
fill='tonexty'))

fig.show()

关于python - Plotly:如何填充线之间的区域?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53459502/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com