使用plotly库画图

plotly支持python nodejs R等多种语言 api完备,功能强大

官方画图示例代码库 https://plot.ly/python/
官方api https://plot.ly/api/


import os import plotly.offline as py #离线使用 在线貌似要收费 import plotly.graph_objs as go import plotly # Create random data with numpy import numpy as np py.init_notebook_mode(connected=True) N = 100 random_x = np.linspace(0, 1, N) random_y0 = np.random.randn(N)+5 random_y1 = np.random.randn(N) random_y2 = np.random.randn(N)-5 # Create traces trace0 = go.Scatter( x = random_x, y = random_y0, mode = 'lines', name = 'lines' ) trace1 = go.Scatter( x = random_x, y = random_y1, mode = 'lines+markers', name = 'lines+markers' ) trace2 = go.Scatter( x = random_x, y = random_y2, mode = 'markers', name = 'markers' ) data = [trace0, trace1, trace2] fileName = 'line-mode.html' ## 如果文件已经存在 先删除 否则运行完成后经常不会自动打开网页 try: os.remove(fileName) except: pass py.plot(data, filename=fileName)
此条目发表在未分类分类目录。将固定链接加入收藏夹。

发表评论