p1: fig
This commit is contained in:
@@ -796,6 +796,60 @@ def plot_combined_range_analysis(
|
||||
return fig
|
||||
|
||||
|
||||
def plot_marginal_benefit_only(
|
||||
df: pd.DataFrame,
|
||||
knee_analysis: Dict,
|
||||
save_path: str = '/Volumes/Files/code/mm/20260130_b/p1/marginal_benefit.png'
|
||||
):
|
||||
"""
|
||||
仅绘制边际收益图(右下角图的简化版)
|
||||
- 长宽比 0.618
|
||||
- 中低饱和度色系
|
||||
- 无标题
|
||||
- 无 Elevator share 线
|
||||
- Y轴范围 450-600
|
||||
"""
|
||||
# 使用0.618黄金比例,缩小尺寸以放大字体
|
||||
fig_width = 8
|
||||
fig_height = fig_width * 0.618
|
||||
fig, ax = plt.subplots(figsize=(fig_width, fig_height))
|
||||
|
||||
T = df['years'].values
|
||||
E = df['energy_PJ'].values
|
||||
|
||||
# 边际节省
|
||||
dE_dT = np.gradient(E, T)
|
||||
marginal_savings = -dE_dT # 每多1年节省的能量
|
||||
|
||||
# 中低饱和度色系
|
||||
color_main = '#4A6FA5' # 灰蓝色
|
||||
color_fill = '#A8C0D8' # 浅灰蓝
|
||||
color_vline = '#B85450' # 暗砖红
|
||||
|
||||
# 边际收益曲线
|
||||
ax.plot(T, marginal_savings, color=color_main, linewidth=2.5, label='Marginal Saving (PJ/year)')
|
||||
ax.fill_between(T, marginal_savings, alpha=0.25, color=color_fill)
|
||||
|
||||
# 标记推荐点
|
||||
rec = knee_analysis['recommended']
|
||||
ax.axvline(x=rec['years'], color=color_vline, linestyle=':', linewidth=2,
|
||||
label=f'Recommended: {rec["years"]:.0f}y')
|
||||
|
||||
ax.set_xlabel('Completion Time (years)', fontsize=11)
|
||||
ax.set_ylabel('Marginal Energy Saving (PJ/year)', fontsize=11)
|
||||
ax.legend(loc='upper right', fontsize=9)
|
||||
ax.grid(True, alpha=0.3)
|
||||
|
||||
# 设置Y轴范围 450-600
|
||||
ax.set_ylim(450, 600)
|
||||
|
||||
plt.tight_layout()
|
||||
plt.savefig(save_path, dpi=150, bbox_inches='tight')
|
||||
print(f"边际收益图已保存至: {save_path}")
|
||||
|
||||
return fig
|
||||
|
||||
|
||||
def plot_combined_decision(
|
||||
df: pd.DataFrame,
|
||||
knee_analysis: Dict,
|
||||
|
||||
Reference in New Issue
Block a user