Python基于plotly模块实现的画图操作示例
2019/7/14 23:39:28
本文主要是介绍Python基于plotly模块实现的画图操作示例,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
本文实例讲述了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相关内容感兴趣的读者可查看本站专题:《Python数学运算技巧总结》、《Python数据结构与算法教程》、《Python函数使用技巧总结》、《Python字符串操作技巧汇总》及《Python入门与进阶经典教程》
希望本文所述对大家Python程序设计有所帮助。
这篇关于Python基于plotly模块实现的画图操作示例的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-21Python编程基础教程
- 2024-11-20Python编程基础与实践
- 2024-11-20Python编程基础与高级应用
- 2024-11-19Python 基础编程教程
- 2024-11-19Python基础入门教程
- 2024-11-17在FastAPI项目中添加一个生产级别的数据库——本地环境搭建指南
- 2024-11-16`PyMuPDF4LLM`:提取PDF数据的神器
- 2024-11-16四种数据科学Web界面框架快速对比:Rio、Reflex、Streamlit和Plotly Dash
- 2024-11-14获取参数学习:Python编程入门教程
- 2024-11-14Python编程基础入门