可视化神器--Plotly Express

  • 时间:2019-06-11 01:56 作者:estate47 来源:estate47 阅读:1834
  • 扫一扫,手机访问
摘要:Plotly Express 是一个新的高级 Python 可视化库:它是 Plotly.py 的高级封装,它为复杂的图表提供了一个简单的语法。用 pip install plotly_express 命令可以安装 Plotly Express。import plotly_express as px

Plotly Express 是一个新的高级 Python 可视化库:它是 Plotly.py 的高级封装,它为复杂的图表提供了一个简单的语法。
用 pip install plotly_express 命令可以安装 Plotly Express。

import plotly_express as pxpx.scatter(gapminder2007, x='gdpPercap', y='lifeExp',color='continent',size='pop',size_max=60,hover_name='country')
px.scatter(gapminder2007, x='gdpPercap', y='lifeExp',color='continent',size='pop',size_max=60,hover_name='country',facet_col ='continent',log_x=True)
px.scatter(gapminder, x='gdpPercap', y='lifeExp',            color='continent', size='pop',            size_max=60, hover_name='country',          animation_frame='year', animation_group='country',          log_x=True, range_x=[10,100000],          range_y=[25,90], labels=dict(pop='Population', gdpPercap='GDP per Capita', lifeExp='Life Expectancy'))
px.choropleth(gapminder, locations='iso_alpha', color='lifeExp',             hover_name='country', animation_frame='year',             color_continuous_scale=px.colors.sequential.Plasma,             projection='natural earth')
iris = px.data.iris()px.scatter(iris, x='sepal_width', y='sepal_length',            color='species', marginal_y='histogram',          marginal_x='box', trendline='ols')
image.png
tips = px.data.tips()px.scatter(tips, x='total_bill', y='tip',facet_row='time',          facet_col='day',color='smoker',trendline='ols',          category_orders={'day':['Thur', 'Fri', 'Sat', 'Sun'], 'time':['Lunch', 'Dinner']})
px.parallel_coordinates(iris, color='species_id',                       color_continuous_scale=px.colors.diverging.Tealrose,                       color_continuous_midpoint=2)
px.parallel_categories(tips, color="size", color_continuous_scale=px.colors.sequential.Inferno)
px.density_contour(iris, x="sepal_width", y="sepal_length")
px.density_contour(iris, x="sepal_width", y="sepal_length", color="species")
px.histogram(tips, x="total_bill", color="smoker", facet_row="day", facet_col="time")
px.box(tips, y="tip", x="sex", color="smoker", facet_col="day", facet_row="time",        category_orders={"day": ["Thur", "Fri", "Sat", "Sun"], "time": ["Lunch", "Dinner"]})
px.violin(tips, y="tip", x="sex", color="smoker", facet_col="day", facet_row="time",         category_orders={"day": ["Thur", "Fri", "Sat", "Sun"], "time": ["Lunch", "Dinner"]})
election = px.data.election()px.scatter_ternary(election, a="Joly", b="Coderre", c="Bergeron", color="winner", size="total", hover_name="district",                   symbol="result",                    size_max=15, color_discrete_map = {"Joly": "blue", "Bergeron": "green", "Coderre":"red"}                  )
px.scatter_3d(election, x="Joly", y="Coderre", z="Bergeron", color="winner", size="total", hover_name="district",                  symbol="result", color_discrete_map = {"Joly": "blue", "Bergeron": "green", "Coderre":"red"})
px.bar_polar(wind, r="value", theta="direction", color="strength", template="plotly_dark",            color_discrete_sequence= px.colors.sequential.Plotly[-2::-1])
px.scatter_matrix(iris, dimensions=["sepal_width", "sepal_length", "petal_width", "petal_length"], color="species")
px.parallel_coordinates(iris, color='species_id', color_continuous_scale=['red','green', 'blue'])
import plotly_express as pxfig = px.scatter(px.data.iris(), x='sepal_width', y='sepal_length', color='species')import plotly.graph_objs as gofig.update(layout=dict(legend=dict(orientation='h',y=1.1,x=0.5),                      annotations=[go.layout.Annotation(text='this one is interesting', x=3.6, y=7.2)]))
  • 全部评论(0)
最新发布的资讯信息
【系统环境|】Tiktok登录教程(2023-02-13 14:17)
【系统环境|】ZORRO佐罗软件安装教程及一键新机使用方法详细简介(2023-02-10 21:56)
【系统环境|】阿里云 centos 云盘扩容命令(2023-01-10 16:35)
【系统环境|】补单系统搭建补单源码搭建(2022-05-18 11:35)
【系统环境|服务器应用】高端显卡再度登上热搜,竟然是因为“断崖式”的降价(2022-04-12 19:47)
【系统环境|软件环境】一步步教你开发、部署第一个去中心化应用 - 宠物商店(2022-03-15 15:13)
【系统环境|软件环境】循序渐进!一文学会高性能开发十大必需掌握的核心技术。(2022-03-15 15:13)
【系统环境|软件环境】Python游戏开发,pygame模块,Python实现贪吃蛇小游戏(2022-03-15 15:13)
【系统环境|软件环境】Spring Cloud Feign 记录单个服务耗时并处理 Hystrix 线程隔离模式!(2022-03-15 15:13)
【系统环境|软件环境】js数组方法全解(2022-03-15 15:12)
手机二维码手机访问领取大礼包
返回顶部