import matplotlib.pyplot as plt
import numpy as np
plt.rcParams['font.sans-serif'] = ['SimHei'] # 用黑体显示中文
plt.rcParams['axes.unicode_minus'] = False # 正常显示负号
# ==========================
# 图1:三年度文件总量对比柱状图
# ==========================
years = ['2022年', '2023年', '2024年']
total_files = [21885, 20576, 18663]
plt.figure(figsize=(10, 6))
bars = plt.bar(years, total_files, color=['#1f77b4', '#ff7f0e', '#2ca02c'])
for bar in bars:
height = bar.get_height()
plt.text(bar.get_x() + bar.get_width()/2., height,
f'{height:,}件',
ha='center', va='bottom', fontsize=10)
plt.annotate('↓6.0%', xy=(1, 21000), xytext=(1, 22000),
arrowprops=dict(arrowstyle='->', color='red'),
ha='center', fontsize=10)
plt.annotate('↓9.3%', xy=(2, 19200), xytext=(2, 22000),
arrowprops=dict(arrowstyle='->', color='red'),
ha='center', fontsize=10)
plt.title('2022-2024年全口径文件量变化趋势', fontsize=14)
plt.ylabel('文件数量(件)', fontsize=12)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.tight_layout()
plt.savefig('图1_三年度文件总量对比.png', dpi=300)
plt.show()
labels = ['统计口径外文件\n95.9%', '统计口径内文件\n4.1%']
sizes = [95.9, 4.1]
explode = (0.05, 0) # 突出显示口径外文件
colors = ['#ff9999', '#66b3ff']
plt.figure(figsize=(8, 8))
patches, texts, autotexts = plt.pie(sizes, explode=explode, labels=labels, colors=colors,
autopct='%1.1f%%', startangle=90, textprops={'fontsize': 12})
for text in texts:
text.set_fontsize(12)
for autotext in autotexts:
autotext.set_fontsize(12)
autotext.set_color('white')
centre_circle = plt.Circle((0,0),0.70,fc='white')
fig = plt.gcf()
fig.gca().add_artist(centre_circle)
plt.text(0, 0, "监管盲区持续扩大", ha='center', va='center', fontsize=14)
plt.title('2024年文件类型占比分析', fontsize=14)
plt.axis('equal') # 保证是圆形
plt.tight_layout()
plt.savefig('图2_2024年文件结构饼图.png', dpi=300)
plt.show()
categories = ['统计口径内文件', '统计口径外文件']
decline_rates = [-26.8, -8.3] # 下降率(负值)
colors = ['#d62728', '#9467bd']
plt.figure(figsize=(10, 6))
bars = plt.bar(categories, decline_rates, color=colors)
for bar in bars:
height = bar.get_height()
plt.text(bar.get_x() + bar.get_width()/2., height-1,
f'{height}%',
ha='center', va='top', color='white', fontsize=12, fontweight='bold')
plt.axhline(y=-8.3, color='gray', linestyle='--', alpha=0.5)
plt.text(1.5, -7, '口径外降幅基准线', fontsize=10, color='gray')
plt.annotate('降幅达3.2倍', xy=(0, -20), xytext=(0, -15),
arrowprops=dict(arrowstyle='->', color='black'),
ha='center', fontsize=12, fontweight='bold')
plt.title('2024年两类文件同比降幅对比', fontsize=14)
plt.ylabel('同比下降百分比(%)', fontsize=12)
plt.ylim(-30, 0) # 扩展y轴范围
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.tight_layout()
plt.savefig('图3_2024年两类文件降幅对比.png', dpi=300)
plt.show()