python对excel数据可视化 plotly_Python数据可视化之-Plotly

这是一篇关于plotly的简单介绍文章,我会在这里以链接和短代码的形式简单介绍plotly的使用。需要注意plotly需要搭配jupyter notebook使用

jupyter notebook的安装:1、打开anaconda prompt ,2、conda install -c conda-forge notebook

如果是pip:pip install notebook

jupyter notebook的启动:win+r命令行窗口 jupyter notebook需要注意使用过程中的命令行窗口不能关闭。

首先是官网:Getting Started with Plotly​plot.ly

不推荐大家看各种网文攻略,质量很差,慢慢对着官网敲效果好很多。

其次Githubhttps://github.com/plotly/plotly.py​github.com

plotly在jupyter下使用需要安装渲染器,同时不同的表格需要不同的库,GitHub这一页基本都有介绍。

具体使用:

plotly提供两种设置图像参数的方法,第一种是python中的字典,第二种是"graph objects"。下面两段短代码生成的图像是一样的:

fig = {

"data": [{"type": "bar",

"x": [1, 2, 3],

"y": [1, 3, 2]}],

"layout": {"title": {"text": "A Bar Chart"}}

}

# To display the figure defined by this dict, use the low-level plotly.io.show function

import plotly.io as pio

pio.show(fig)

import plotly.graph_objects as go

fig = go.Figure(

data=[go.Bar(x=[1, 2, 3], y=[1, 3, 2])],

layout=go.Layout(

title=go.layout.Title(text="A Bar Chart")

)

)

fig.show()

设置底色和水印教程:Theming and templates​plot.ly

以及简单图像的地图示例:全球人口分布的bubble图

import plotly.express as px

df = px.data.gapminder().query("year==2007")

fig = px.scatter_geo(df, locations="iso_alpha", color="continent",

hover_name="country", size="pop",

projection="natural earth")

fig.show()

实操案例:https://plot.ly/python/visualizing-mri-volume-slices/​plot.ly

最后贴一个还不错的文章http://www.pianshen.com/article/5500341648/​www.pianshen.com

后面我会在实际处理数据后更新相关使用的方法和自己的源码。

今天开始数据可视化学习算是正式提上了日程吧,一点点做笔记,慢慢来。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值