绘图工具echarts——散点图、漏斗图、仪表盘图、水球图、饼状图

散点图

  • 案例: 北京3月份每天白天的最高气温统计
from pyecharts import EffectScatter, Scatter, Scatter3D

x_march = list(range(1, 32))
y_temp_march = [11, 17, 16, 11, 12, 11, 12, 6, 6, 7, 8, 9, 12, 15, 14, 17, 18, 21, 16, 17, 20, 14, 15, 15, 15, 19, 21, 22, 22, 22, 23]

# scatter= EffectScatter("北京3月份每天白天的最高气温随时间(天)变化的散点图")
scatter= Scatter("北京3月份白天变化的散点图", subtitle="xxxx")
# symbol_size散点图标记的大小;
scatter.add("3 月", x_march, y_temp_march, symbol_size=10, line_color='red')
scatter.add("4 月", x_march, y_temp_march, symbol_size=30)
scatter.render()

漏斗图

  • 案例: 统计四部电影票房
from pyecharts import Funnel

x_movies_name = ["猩球崛起", "敦刻尔克", "蜘蛛侠", "战狼2"]
y_16 = [20, 40, 60, 80]
funnel = Funnel("xxxx")
funnel.add("电影信息", x_movies_name, y_16)
funnel.render()

仪表盘图

  • 案例: 记录CPU使用率
from pyecharts import  Gauge
import psutil

cpu_percent = psutil.cpu_percent()
print(cpu_percent)
gauge = Gauge("CPU使用率")
gauge.add("cpu", "CPU使用率", cpu_percent)
gauge.render()

水球图

  • 案例:
from pyecharts import  Liquid
import psutil

liquid = Liquid("xxxx")
liquid.add("Liquid", [0.6, 0.5, 0.4, 0.3],  shape='pin')
liquid.render()

饼状图

  • 案例:
from pyecharts import  Pie

attr = ["男", '女', '其他']
data = [100, 180, 2]
pie = Pie("example")
# 是否直接显示label信息
pie.add("", attr, data, is_label_show=True)
pie.render()

你可能感兴趣的:(python)