可视化模块 pyecharts

pyecharts 真的是数据可视化编程利器啊,简单上一波代码,就不详细描述了
import os,json,sys,time
from pyecharts import options as opts
from pyecharts.charts import Bar
from pyecharts.globals import ThemeType
from pyecharts.charts import Page
from pyecharts.faker import Faker
from pyecharts.components import Table




def get_bar(name,attr,value,theme_type):
    # attr 是属性,value 是基础数据
    bar=Bar(init_opts=opts.InitOpts(theme=theme_type))
    bar.add_xaxis(attr)
    bar.add_yaxis("成绩分数", value)
    bar.set_global_opts(title_opts=opts.TitleOpts(title="{0} 成绩示意图,总分 {1}".format(name,sum(value)), subtitle="2022 年展示"))
    return(bar)

def get_table(name,attr,value,theme_type):
    table = Table()
    headers = ["序号", "属性", "值"]
    module_data = [[i + 1, attr[i], value[i] ] for i in range(len(attr))]
    table.set_global_opts(title_opts=opts.TitleOpts(title="{0} 成绩示意图,总分 {1}".format(name,sum(value)), subtitle="2022 年展示"))
    table.add(headers, module_data)
    return(table)

attr=["历史","英语","中文","体育","数学","地理"]
value=[60,100,50,79,85,65]
page=Page()
mybar=get_bar("小明的成绩",attr,value,ThemeType.VINTAGE)
page.add(mybar)
mytable=get_table("小明的成绩",attr,value,ThemeType.LIGHT)
page.add(mytable)


page.render(r"ada.html")
os.system(r"ada.html")

下面是展示的结果

可视化模块 pyecharts_第1张图片

 可视化模块 pyecharts_第2张图片

 

你可能感兴趣的:(#,Python,第三方模块,python,开发语言)