From b85c2c86097d8e94340a21c9e78cd1ddf3899da3 Mon Sep 17 00:00:00 2001 From: xxx Date: Fri, 31 May 2024 11:02:32 +0800 Subject: [PATCH] 666 --- 公司类型环形图.html | 140 +++++++++++++++++++++++++++++++++ 公司类型环形图.py | 31 ++++++++ 就业机会前十的城市.py | 42 ++++++++++ 3 files changed, 213 insertions(+) create mode 100644 公司类型环形图.html create mode 100644 公司类型环形图.py create mode 100644 就业机会前十的城市.py diff --git a/公司类型环形图.html b/公司类型环形图.html new file mode 100644 index 0000000..c5b65ee --- /dev/null +++ b/公司类型环形图.html @@ -0,0 +1,140 @@ + + + + + Awesome-pyecharts + + + + + +
+ + + diff --git a/公司类型环形图.py b/公司类型环形图.py new file mode 100644 index 0000000..24a0785 --- /dev/null +++ b/公司类型环形图.py @@ -0,0 +1,31 @@ +import pandas as pd +from pyecharts.charts import Pie +from pyecharts import options as opts +from pyecharts.globals import ThemeType + +data = [ + ["上市公司", 192], + ["事业单位", 2], + [ "其它", 71], + [ "合资", 39], + [ "国企", 80], + [ "外商独资", 289], + [ "民营", 714], + [ "港澳台公司", 4], + [ "股份制企业", 132] +] + +pie=Pie(init_opts=opts.InitOpts(theme=ThemeType.INFOGRAPHIC))\ + .add("公司类型环形图", + data, + radius=["20%","40%"], + center=['50%','40%'], + label_opts=opts.LabelOpts(formatter='{b}:{d}%') + )\ + .set_global_opts( + title_opts=opts.TitleOpts('公司类型',pos_left="35%",pos_top="3%", + title_textstyle_opts=opts.TextStyleOpts(font_size=25)), + legend_opts=opts.LegendOpts(orient="vertical",pos_left='15%',pos_top='15%') + ) + +pie.render("公司类型环形图.html") \ No newline at end of file diff --git a/就业机会前十的城市.py b/就业机会前十的城市.py new file mode 100644 index 0000000..508332a --- /dev/null +++ b/就业机会前十的城市.py @@ -0,0 +1,42 @@ +import matplotlib.pyplot as plt +import pandas as pd + +# 解决中文乱码 +plt.rcParams['font.sans-serif'] = ['SimHei'] +# 创建画布 +plt.figure() + +data=pd.read_csv("最新数据.csv") +# 将城市这一列数据提取出来 +city = data[["城市",'职位名称']] +# 将城市列去重后转化为列表变成x轴数据 +x_data = data['城市'].drop_duplicates().tolist() +x_data=x_data[:10] +# print(x_data) + +# 将城市进行分组计数变为y轴数据 +y_data = city.groupby('城市').count().reset_index() +y_data = y_data['职位名称'].tolist() +y_data.sort(reverse=True) +y_data=y_data[:10] + +plt.bar(x_data, y_data, + width=0.5, + color='#9fe080', + align="center", + ) + +# 显示数据标签 +for a,b in zip(x_data,y_data): + plt.text( + a, #标签的x坐标 + b, #标签的y坐标 + b, #标签的内容 + ha='center', + va='bottom', + fontsize=10) + +plt.title("就业机会前十的城市") +plt.xlabel("城市") + +plt.show() \ No newline at end of file