澳门六合彩官网 用python编程把柄各科平平分绘图条形统计图

发布日期:2024-06-14 16:28    点击次数:116

1.各科平平分表格如下图

各班各科平平分

别再羡慕朋友圈那些滤镜下的风景了,真的,来腾冲,你会发现,最美的风景其实都在日常里。这里没有大理的“风花雪月”,也没有丽江的“灯红酒绿”,有的只是最接地气的人情味和让你瞬间安静下来的神奇魔力。一年四季平均20℃的气温,真的舒服到爆炸,就像一位温柔的老朋友,用它的真实和温暖,悄悄地治愈着你所有的疲惫。

2.代码结束:

import pandas as pdimport matplotlib.pyplot as pltdef plot_subject_scores: try: # 读取平平分数据 df = pd.read_excel('平平分.xlsx') # 建筑中笔墨体 plt.rcParams['font.sans-serif'] = ['SimHei'] plt.rcParams['axes.unicode_minus'] = False # 界说学科列表 subjects = ['语文', '数学', '英语', '科学', '历史与社会'] # 为每个学科创建单独的条形图 for subject in subjects: plt.figure(figsize=(12, 6)) # 创建条形图 bars = plt.bar(df['班级'], df[subject], color='#1f77b4') # 在条形上方添加数值标签 for bar in bars: height = bar.get_height plt.text(bar.get_x + bar.get_width/2., height, f'{height:.1f}', ha='center', va='bottom') # 建筑图表属性 plt.title(f'{subject}平平分漫衍') plt.xlabel('班级') plt.ylabel('平平分') plt.xticks(rotation=45) plt.grid(True, axis='y', linestyle='--', alpha=0.7) # 更始布局 plt.tight_layout # 保存图表 plt.savefig(f'{subject}平平分统计图.png', dpi=300, bbox_inches='tight') print(f"已保存:{subject}平平分统计图.png") print("通盘统计图生成完成!") except FileNotFoundError: print("乖僻:找不到平平分.xlsx文献") except Exception as e: print(f"发生乖僻:{str(e)}")if __name__ == '__main__': plot_subject_scores

例:各班语文平平分条形统计图

各班数学平平分条形统计图澳门六合彩官网