python报表可视化(使用Python快速制作可视化报表的方法)
类别:脚本大全 浏览量:2361
时间:2022-04-03 12:38:42 python报表可视化
使用Python快速制作可视化报表的方法我们可以试用可视化包——pyechart。
echarts是百度开源的一个数据可视化js库,主要用于数据可视化。
pyecharts是一个用于生成echarts图标的类库。实际就是echarts与python的对接。
安装
pyecharts兼容python2和python3。执行代码:
pip install pyecharts(快捷键windows+r——输入cmd)
初级图表
1.柱状图/条形图
|
from pyecharts import bar attr = [ "衬衫" , "羊毛衫" , "雪纺衫" , "裤子" , "高跟鞋" , "袜子" ] v1 = [ 5 , 20 , 36 , 10 , 75 , 90 ] v2 = [ 10 , 25 , 8 , 60 , 20 , 80 ] bar = bar( "各商家产品销售情况" ) bar.add( "商家a" ,attr,v1,is_stack = true) bar.add( "商家b" ,attr,v2,is_stack = true) bar #bar.render() |
2.饼图
|
from pyecharts import pie attr = [ "衬衫" , "羊毛衫" , "雪纺衫" , "裤子" , "高跟鞋" , "鞋子" ] v1 = [ 11 , 12 , 13 , 10 , 10 , 10 ] pie = pie( "各产品销售情况" ) pie.add("",attr,v1,is_label_show = true) pie #pie.render() |
3.圆环图
|
from pyecharts import pie attr = [ "衬衫" , "羊毛衫" , "雪纺衫" , "裤子" , "高跟鞋" , "鞋子" ] v1 = [ 11 , 12 , 13 , 10 , 10 , 10 ] pie = pie( "饼图—圆环图示例" ,title_pos = "center" ) pie.add("",attr,v1,radius = [ 40 , 75 ],label_text_color = none, is_label_show = true,legend_orient = "vertical" , legend_pos = "left" ) pie |
4.散点图
|
from pyecharts import scatter v1 = [ 10 , 20 , 30 , 40 , 50 , 60 ] v2 = [ 10 , 20 , 30 , 40 , 50 , 60 ] scatter = scatter( "散点图示例" ) scatter.add( "a" ,v1,v2) scatter.add( "b" ,v1[:: - 1 ],v2) scatter |
5.仪表盘
|
from pyecharts import gauge gauge = gauge( "业务指标完成率—仪表盘" ) gauge.add( "业务指标" , "完成率" , 66.66 ) gauge |
6.热力图
|
import random from pyecharts import heatmap x_axis = [ "12a" , "1a" , "2a" , "3a" , "4a" , "5a" , "6a" , "7a" , "8a" , "9a" , "10a" , "11a" , "12p" , "1p" , "2p" , "3p" , "4p" , "5p" , "6p" , "7p" , "8p" , "9p" , "10p" , "11p" ,] y_axis = [ "saturday" , "friday" , "thursday" , "wednesday" , "tuesday" , "monday" , "sunday" ] data = [[i,j,random.randint( 0 , 50 )] for i in range ( 24 ) for j in range ( 7 )] heatmap = heatmap() heatmap.add( "热力图直角坐标系" ,x_axis,y_axis,data,is_visualmap = true, visual_text_color = "#000" ,visual_orient = "horizontal" ) heatmap |
高级图表
1.漏斗图
|
from pyecharts import funnel attr = [ "潜在" , "接触" , "意向" , "明确" , "投入" , "谈判" , "成交" ] value = [ 140 , 120 , 100 , 80 , 60 , 40 , 20 ] funnel = funnel( "销售管理分析漏斗图" ) funnel.add( "商品" ,attr,value,is_label_show = true, label_pos = "inside" ,label_text_color = "#fff" ) funnel |
2.词云图
|
from pyecharts import wordcloud name = [ "sam s club" , "macys" , "amy schumer" , "jurassic world" , "charter communications" , "chick fil a" , "planet fitness" , "pitch perfect" , "express" , "home" , "johnny depp" , "lena dunham" , "lewis hamilton" , "kxan" , "mary ellen mark" , "farrah abraham" , "rita ora" , "serena williams" , "ncaa baseball tournament" , "point break" ] value = [ 10000 , 6181 , 4386 , 4055 , 2467 , 2244 , 1898 , 1484 , 1112 , 965 , 847 , 582 , 555 , 550 , 462 , 366 , 360 , 282 , 273 , 265 ] wordcloud = wordcloud(width = 1300 ,height = 620 ) wordcloud.add("",name,value,word_size_range = [ 20 , 100 ]) wordcloud |
3.组合图
|
from pyecharts import line,pie,grid line = line( "折线图" ,width = 1200 ) attr = [ "周一" , "周二" , "周三" , "周四" , "周五" , "周六" , "周日" ] line.add( "最高气温" ,attr,[ 11 , 11 , 15 , 13 , 12 , 13 , 10 ], mark_point = [ "max" , "min" ],mark_line = [ "average" ]) line.add( "最低气温" ,attr,[ 1 , - 2 , 2 , 5 , 3 , 2 , 0 ], mark_point = [ "max" , "min" ],mark_line = [ "average" ], legend_pos = "20%" ) attr = [ "衬衫" , "羊毛衫" , "雪纺衫" , "裤子" , "高跟鞋" , "袜子" ] v1 = [ 11 , 12 , 13 , 10 , 10 , 10 ] pie = pie( "饼图" ,title_pos = "55%" ) pie.add("",attr,v1,radius = [ 45 , 65 ],center = [ 65 , 50 ], legend_pos = "80%" ,legend_orient = "vertical" ) grid = grid() grid.add(line,grid_right = "55%" ) grid.add(pie,grid_left = "60%" ) grid |
以上这篇使用python快速制作可视化报表的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持开心学习网。
原文链接:https://blog.csdn.net/weixin_41774060/article/details/79419315
您可能感兴趣
- pythonexcel生成报表(python生成每日报表数据Excel并邮件发送的实例)
- python真的能高效处理excel报表吗(Python数据报表之Excel操作模块用法分析)
- pythonexcel报表实例(对python生成业务报表的实例详解)
- python报表可视化(使用Python快速制作可视化报表的方法)
- python分析excel基础数据生成报表(Python实现定制自动化业务流量报表周报功能XlsxWriter模块)
- 红色代表什么(红色代表什么情感和含义)
- 南宋志南和尚绝句 杨柳风似庙中来(南宋志南和尚绝句)
- 今天要穿什么颜色(今天要穿什么颜色的衣服最吉利)
- 一道高中题-求杯子的高度(一道高中题-求杯子的高度)
- 网坛停摆三巨头亏损惨重,费德勒跌幅88 纳达少赚2400万(网坛停摆三巨头亏损惨重)
- Beyond 版本《无人深空》主线任务攻略 阿特拉斯之道(版本无人深空主线任务攻略)
热门推荐
- 在css中width是什么意思(Css深刻理解width:auto的用法)
- 如何删除docker中已停止的容器(一条命令重启所有已停止的docker容器操作)
- 云主机有哪些劣势(云主机怎么使用?用途有哪些?)
- 护卫神主机管理系统(护卫神主机大师如何开启和关闭主机管理系统?)
- js操作iframe
- sqlserver2016的安装(Sql Server2016 正式版安装程序图解教程)
- php教程字符串类型进阶技术教程(PHP中有关长整数的一些操作教程)
- sql server存储过程详解(SQL Server存储过程中编写事务处理的方法小结)
- html5复制修改(HTML5实现无刷新修改URL的方法)
- css无效的常见原因