import plotly as py
import plotly.graph_objs as go
import numpy as np
if __name__ == '__main__':
count = 30
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=None,
mode='lines',
name="甲"
)
trace2 = go.Scatter(
x=ax,
y=y2,
fill='tonexty',
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')
如图:
数据:
[1.81948906 1.90986031 1.97874382 1.95696095 1.46951918 1.75425346
1.74950135 1.51535676 1.28641076 1.71494238 1.53612186 1.73244425
1.45686196 1.34514254 1.05324027 1.90008688 1.42644222 1.29122902
1.56588033 1.51585383 1.49433673 1.45560525 1.03639483 1.48588834
1.18956677 1.17175237 1.0139798 1.10591103 1.47639936 1.4111587 ]
[2.80834863 2.84134552 2.8841477 2.61683362 2.14689641 2.13235801
2.17955131 2.82645101 2.75209502 2.8165865 2.00936273 2.82707883
2.64675513 2.40060479 2.40211049 2.11151292 2.80820837 2.76651774
2.02275856 2.66341215 2.17598552 2.67787399 2.2671058 2.62285852
2.34989048 2.9897749 2.13490803 2.32264514 2.48409108 2.20066351]