plotly堆叠残差围成的面积图,Python

  1. import plotly as py
  2. import plotly.graph_objs as go
  3. import numpy as np
  4. if __name__ == '__main__':
  5. count = 30
  6. ax = [a for a in range(count)]
  7. y1 = np.random.random(count) + 1
  8. print(y1)
  9. y2 = np.random.random(count) + 2
  10. print(y2)
  11. trace1 = go.Scatter(
  12. x=ax,
  13. y=y1,
  14. fill=None,
  15. mode='lines',
  16. name="甲"
  17. )
  18. trace2 = go.Scatter(
  19. x=ax,
  20. y=y2,
  21. fill='tonexty',
  22. mode='none',
  23. name="乙"
  24. )
  25. data = [trace1, trace2]
  26. layout = dict(title='一条曲线',
  27. xaxis=dict(title='时间'),
  28. yaxis=dict(title='对比参照'),
  29. )
  30. fig = dict(data=data, layout=layout)
  31. py.offline.plot(fig, filename='fig.html')

如图:

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly96aGFuZ3BoaWwuYmxvZy5jc2RuLm5ldA_size_16_color_FFFFFF_t_70

数据:

  1. [1.81948906 1.90986031 1.97874382 1.95696095 1.46951918 1.75425346
  2. 1.74950135 1.51535676 1.28641076 1.71494238 1.53612186 1.73244425
  3. 1.45686196 1.34514254 1.05324027 1.90008688 1.42644222 1.29122902
  4. 1.56588033 1.51585383 1.49433673 1.45560525 1.03639483 1.48588834
  5. 1.18956677 1.17175237 1.0139798 1.10591103 1.47639936 1.4111587 ]
  6. [2.80834863 2.84134552 2.8841477 2.61683362 2.14689641 2.13235801
  7. 2.17955131 2.82645101 2.75209502 2.8165865 2.00936273 2.82707883
  8. 2.64675513 2.40060479 2.40211049 2.11151292 2.80820837 2.76651774
  9. 2.02275856 2.66341215 2.17598552 2.67787399 2.2671058 2.62285852
  10. 2.34989048 2.9897749 2.13490803 2.32264514 2.48409108 2.20066351]

发表评论

表情:
评论列表 (有 0 条评论,63人围观)

还没有评论,来说两句吧...

相关阅读