import plotly as py
import plotly.graph_objs as go
import numpy as np
if __name__ == '__main__':
count = 20
ax = [a for a in range(count)]
y1 = np.random.random(count) + 1
print(y1)
y2 = np.random.random(count) + 2
print(y2)
trace1 = go.Scatter(
x=ax,
y=y1,
fill='tonexty',
mode='none', # 无边界线
name="甲"
)
trace2 = go.Scatter(
x=ax,
y=y2,
fill='tozeroy',
mode='none', # 无边界线
name="乙"
)
data = [trace1, trace2]
layout = dict(title='曲线',
xaxis=dict(title='时间'),
yaxis=dict(title='对比参照'),
)
fig = dict(data=data, layout=layout)
py.offline.plot(fig, filename='fig.html')
如图: