Python College Entrance Examination | matplotlib draws the distribution chart of the number of college entrance examination students and admission rates from 1977 to 2022

Release: 2023-08-09 15:45:06
forward
1643 people have browsed it


##This issue is based on 1977-2022 previous college entrance examination number and number of admissions, Use python's matplotlib library to draw the corresponding distribution bar chart, I hope it will be helpful to everyone, If you have any questions or If you need improvement, please contact the editor.


#1. Data

##
df = pd.read_excel('1977-2022历届高考录取率.xlsx')
Copy after login
Python College Entrance Examination | matplotlib draws the distribution chart of the number of college entrance examination students and admission rates from 1977 to 2022
2. 绘图

2.1 绘制表头

ax.text(270, tit_pos, '年份', ha='center', va='bottom', fontsize=12, fontweight='heavy',color='#00695C')
ax.text(1100, tit_pos, '高考人数', ha='center', va='bottom', fontsize=12, fontweight='heavy',color='#00695C')
ax.text(2700, tit_pos, '录取人数', ha='center', va='bottom', fontsize=12, fontweight='heavy',color='#00695C')
ax.text(3700, tit_pos, '录取率', ha='center', va='bottom', fontsize=12, fontweight='heavy',color='#00695C')
Copy after login

2.2 绘制报考分数、录取人数条形图

years = df['年份'].values.tolist()
x = df['报考人数(人)'].values.tolist()
y = df['高校录取人数(人)'].values.tolist()
z = df['录取比例'].values.tolist()
ax.barh(years, x, left=550,tick_label=labels, height=0.5)
ax.barh(years, y, left=2200,tick_label=labels, height=0.5)
Copy after login
2.3 绘制录取率散点图
ax.scatter([3700]*len(z), years)
Copy after login

2.4 设置标题

ax.text(600, 50, '1977-2022年历届高考人数及录取率', fontdict={'color': '#880E4F', 'size': 20}, fontweight='heavy')
ax.text(1250, 49, '(-- 制图@公众号:Python当打之年 --)', fontsize = 9, fontweight='heavy',alpha=1)
Copy after login
效果如下

Python College Entrance Examination | matplotlib draws the distribution chart of the number of college entrance examination students and admission rates from 1977 to 2022


The above is the detailed content of Python College Entrance Examination | matplotlib draws the distribution chart of the number of college entrance examination students and admission rates from 1977 to 2022. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:Python当打之年
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template