Plotly中的Filled Area Plots

填充区域图

效果图

Filled Area Plots

代码

1
2
3
4
5
6
7
8
import plotly.graph_objects as go

fig = go.Figure()
fig.add_trace(go.Scatter(x=[1, 2, 3, 4], y=[0, 2, 3, 5], fill='tozeroy')) # fill down to xaxis
fig.add_trace(go.Scatter(x=[1, 2, 3, 4], y=[3, 5, 1, 7], fill='tonexty')) # fill to trace0 y

fig.show()

内部填充面积图

效果

In-Filling

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import plotly.graph_objects as go

fig = go.Figure()
fig.add_trace(go.Scatter(
x=[1, 2, 3, 4],
y=[3, 4, 8, 3],
fill=None,
mode='lines',
line_color='indigo',))
fig.add_trace(go.Scatter(
x=[1, 2, 3, 4],
y=[1, 6, 2, 6],
fill='tonexty', # fill area between trace0 and trace1
mode='lines', line_color='indigo'))

fig.show()