Reputation: 1309
I meet difficult in building horizon graph with plotly
. I succeed in building this with matplotlib.plotly
using demo code from Implementing horizon charts in matplotlib, but fail with plotly
because I couldn't find any function to achieve fill_between
in plotly
.
I am wondering how to fill an area between two broken line in plotly
.
Upvotes: 4
Views: 9114
Reputation: 61084
Just use fill=tozeroy
like this:
Plot:
Code:
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()
Upvotes: 5