fig, ax1 = plt.subplots(figsize=(10, 6))
# 左轴:营业利润
ax1.set_xlabel('年份', fontsize=12)
ax1.set_ylabel('营业利润(亿元)', fontsize=12, color='steelblue')
ax1.plot(demo_profit.index, demo_profit.values,
color='steelblue', marker='o', linewidth=2.5, label='营业利润')
ax1.tick_params(axis='y', labelcolor='steelblue')
ax1.grid(True, alpha=0.3, linestyle='--')
# 右轴:增长率
ax2 = ax1.twinx()
ax2.set_ylabel('增长率(%)', fontsize=12, color='coral')
ax2.plot(growth_demo.index, growth_demo.values,
color='coral', marker='s', linewidth=2.5, label='增长率')
ax2.tick_params(axis='y', labelcolor='coral')
ax2.axhline(y=0, color='gray', linestyle='--', linewidth=1, alpha=0.7)
# 标记负增长区间
ax2.fill_between(growth_demo.index, 0, growth_demo.values,
where=(growth_demo.values < 0),
color='red', alpha=0.2, label='负增长区间')
plt.title('营业利润与增长率趋势', fontsize=14, pad=15)
lines1, labels1 = ax1.get_legend_handles_labels()
lines2, labels2 = ax2.get_legend_handles_labels()
ax1.legend(lines1 + lines2, labels1 + labels2, loc='upper left')
fig.tight_layout()
plt.show()