您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
本篇文章给大家分享的是有关如何在Python中使用plotly模块画图,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。
具体如下:
import plotly plotly.tools.set_credentials_file(username='tianjixuetu', api_key='xxxxxxxx')#此处要去官网申请自己的api,#https://plot.ly/ssu/
#案例1 import plotly.plotly as py from plotly.graph_objs import * trace0 = Scatter( x=[1, 2, 3, 4], y=[10, 15, 13, 17] ) trace1 = Scatter( x=[1, 2, 3, 4], y=[16, 5, 11, 9] ) data = Data([trace0, trace1]) py.plot(data, filename = 'basic-line')
#案例2 import plotly.graph_objs as go import plotly.plotly as py import numpy as np colorscale = [[0, '#FAEE1C'], [0.33, '#F3558E'], [0.66, '#9C1DE7'], [1, '#581B98']] trace1 = go.Scatter( y = np.random.randn(500), mode='markers', marker=dict( size='16', color = np.random.randn(500), colorscale=colorscale, showscale=True ) ) data = [trace1] url_1 = py.plot(data, filename='scatter-for-dashboard', auto_open=False) py.iplot(data, filename='scatter-for-dashboard') url_1
#案例3 import plotly.plotly as py import plotly.graph_objs as go import numpy as np x0 = np.random.randn(50) x1 = np.random.randn(50) + 2 x2 = np.random.randn(50) + 4 x3 = np.random.randn(50) + 6 colors = ['#FAEE1C', '#F3558E', '#9C1DE7', '#581B98'] trace0 = go.Box(x=x0, marker={'color': colors[0]}) trace1 = go.Box(x=x1, marker={'color': colors[1]}) trace2 = go.Box(x=x2, marker={'color': colors[2]}) trace3 = go.Box(x=x3, marker={'color': colors[3]}) data = [trace0, trace1, trace2, trace3] url_2 = py.plot(data, filename='box-plots-for-dashboard', sharing='public', auto_open=True,world_readable=True) py.iplot(data, filename='box-plots-for-dashboard') url_2
以上就是如何在Python中使用plotly模块画图,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注亿速云行业资讯频道。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。