Python-Pyecharts画图(饼图,雷达图,词云)[二]

使用Pyecharts画图可以使图像富有动态

Scatter 散点图

Bar 柱状图

Pie 饼状图

Line折线图/面积图

Radar 雷达图

Sankey 桑葚图

WordCloud 词云图

Funnel 漏斗图

Gauge 仪表盘

Graph 关系图

Liquid 水球图

Parallel 平行坐标系

Polar 极坐标系

HeatMap 热力图

饼图

普通饼状图
from pyecharts.charts import Pie  
import pyecharts.options as opts  

num = [110, 136, 108, 48, 111, 112, 103] 
lab = ['哈士奇', '萨摩耶', '泰迪', '金毛', '牧羊犬', '吉娃娃', '柯基']  
x = [(i, j)for i, j in zip(lab, num)]  
(
    Pie()
    .add(series_name='饼状',data_pair=[(i, j) for i, j in zip(lab, num)],)#注意传入的数据
    .set_global_opts(title_opts=opts.TitleOpts(title="Pie示例"))#标题
    .set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {d}%"))#使用百分比
    #.set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}"))#不使用百分比
    .render('G:/HTML图/饼状.html')
)

Python-Pyecharts画图(饼图,雷达图,词云)[二]_第1张图片

玫瑰图图
#玫瑰图
from pyecharts.charts import Pie  
import pyecharts.options as opts  

num = [110, 136, 108, 48, 111, 112, 103]  
lab = ['哈士奇', '萨摩耶', '泰迪', '金毛', '牧羊犬', '吉娃娃', '柯基']  
x = [(i, j)for i, j in zip(lab, num)]  
(
    Pie()
    .add(series_name='饼状',data_pair=[(i, j) for i, j in zip(lab, num)],rosetype='radius',radius=[100,150])#注意传入的数据
    .set_global_opts(title_opts=opts.TitleOpts(title="Pie示例"))#标题
    .set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}"))#给图形的样式添加数据
    .render('G:/HTML图/饼状——玫瑰图.html')
)

Python-Pyecharts画图(饼图,雷达图,词云)[二]_第2张图片

南丁格尔图
#南丁格尔图
from pyecharts.charts import Pie  
import pyecharts.options as opts  

num = [110, 136, 108, 48, 111, 112, 103]  
lab = ['哈士奇', '萨摩耶', '泰迪', '金毛', '牧羊犬', '吉娃娃', '柯基']  
x = [(i, j)for i, j in zip(lab, num)]  
(
    Pie()
    .add(series_name='饼状',data_pair=[(i, j) for i, j in zip(lab, num)],rosetype='radius')#注意传入的数据
    .set_global_opts(title_opts=opts.TitleOpts(title="Pie示例"))#标题
    .set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}"))#给图形的样式添加数据
    .render('G:/HTML图/饼状-南丁格尔图.html')
)
  

Python-Pyecharts画图(饼图,雷达图,词云)[二]_第3张图片

雷达图


import pandas as pd

from pyecharts import options as opts
from pyecharts.charts import Radar

# 例1 基本示例
v1=[[120,112,45,50,70,90,20,30]]   # 数据必须为二维数组,否则会集中一个指示器显示
v2=[[80,90,120,50,60,85,5,15]]
radar1=(
    Radar()
    .add_schema(# 添加schema架构
        
        
        schema=[
            {
     "name": "常住人口", "max": 150, "min": -1,"color":'black',"font_size":18},
                {
     "name": "现有办公人口", "max": 150, "min": -1,"color":'black',"font_size":18},
                {
     "name": "企业数量", "max": 150, "min": -1,"color":'black',"font_size":18},
                {
     "name": "新增招聘人口", "max": 150,"min":-1,"color":'black',"font_size":18},
                {
     "name": "平均月薪", "max": 150,"min":-1,"color":'black',"font_size":18},
        ],shape='circle'# 设置雷达图类型圆形
        

    )
    .add('budget',v1,color = 'blue')# 添加一条数据,参数1为数据名,参数2为数据
    .add('fact',v2,color = 'green') # schema有几个indicator指示器就会默认取前几个数值
    .set_global_opts(title_opts=opts.TitleOpts(title='radar 基本示例'),)
)
radar1.render('.雷达图.html')

Python-Pyecharts画图(饼图,雷达图,词云)[二]_第4张图片

词云图

# 导入WordCloud及配置模块
from pyecharts import options as opts
from pyecharts.charts import WordCloud
from pyecharts.globals import SymbolType

# 添加词频数据
words = [
    ("Sam S Club", 10000),
    ("Macys", 6181),
    ("Amy Schumer", 4386),
    ("Jurassic World", 4055),
    ("Charter Communications", 2467),
    ("Chick Fil A", 2244),
    ("Planet Fitness", 1868),
    ("Pitch Perfect", 1484),
    ("Express", 1112),
    ("Home", 865),
    ("Johnny Depp", 847),
    ("Lena Dunham", 582),
    ("Lewis Hamilton", 555),
    ("KXAN", 550),
    ("Mary Ellen Mark", 462),
    ("Farrah Abraham", 366),
    ("Rita Ora", 360),
    ("Serena Williams", 282),
    ("NCAA baseball tournament", 273),
    ("Point Break", 265),
]

# WordCloud模块,链式调用配置,最终生成html文件
c = (
    WordCloud()
    .add("", words, word_size_range=[20, 100], shape=SymbolType.DIAMOND)
    .set_global_opts(title_opts=opts.TitleOpts(title="WordCloud-shape-diamond"))
    .render("wordcloud_diamond.html")
)


Python-Pyecharts画图(饼图,雷达图,词云)[二]_第5张图片
谢谢点赞评论!

你可能感兴趣的:(python,可视化Pyecharts,python,数据可视化)