p1: figlambda
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1 +1,3 @@
|
||||
latex/
|
||||
__pycache__/
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -840,5 +840,63 @@ def main():
|
||||
return df, sensitivity_results
|
||||
|
||||
|
||||
def plot_total_cost_standalone(
|
||||
df: pd.DataFrame = None,
|
||||
save_path: str = '/Volumes/Files/code/mm/20260130_b/p1/total_cost_curves.png'
|
||||
):
|
||||
"""
|
||||
单独绘制总成本曲线图
|
||||
- 长宽比 0.618
|
||||
- 删去标题
|
||||
- 删去 λ=500,添加目标 λ=504
|
||||
- 低偏中饱和度色系
|
||||
"""
|
||||
if df is None:
|
||||
df = generate_tradeoff_curve()
|
||||
|
||||
# 使用0.618黄金比例
|
||||
fig_width = 8
|
||||
fig_height = fig_width * 0.618
|
||||
fig, ax = plt.subplots(figsize=(fig_width, fig_height))
|
||||
|
||||
years = df['years'].values
|
||||
|
||||
# 低偏中饱和度配色(删去500,添加504)
|
||||
lambda_colors = [
|
||||
(450, '#6B9B78'), # 灰绿色
|
||||
(480, '#B87B6B'), # 灰橙红色
|
||||
(504, '#8B7BA8'), # 灰紫色(目标λ)
|
||||
(550, '#5B8FA8'), # 灰蓝色
|
||||
]
|
||||
|
||||
for lam, color in lambda_colors:
|
||||
total_cost = calculate_total_cost(df, lam)
|
||||
linewidth = 2.5 if lam == 504 else 2
|
||||
linestyle = '-'
|
||||
label = f'λ={lam} PJ/year' if lam != 504 else f'λ={lam} PJ/year (target)'
|
||||
|
||||
ax.plot(years, total_cost / 1000, color=color, linestyle=linestyle,
|
||||
linewidth=linewidth, label=label)
|
||||
|
||||
# 标记最小值点
|
||||
opt = find_optimal_point(df, lam)
|
||||
markersize = 11 if lam == 504 else 9
|
||||
ax.plot(opt['years'], opt['total_cost'] / 1000, 'o', color=color,
|
||||
markersize=markersize, markeredgecolor='#333333', markeredgewidth=1.5)
|
||||
|
||||
ax.set_xlabel('Construction Timeline T (years)', fontsize=11)
|
||||
ax.set_ylabel('Total Cost J = E + λT (×10³ PJ)', fontsize=11)
|
||||
ax.legend(loc='upper right', fontsize=9)
|
||||
ax.grid(True, alpha=0.3)
|
||||
ax.set_xlim(95, 200)
|
||||
ax.set_ylim(95, 130)
|
||||
|
||||
plt.tight_layout()
|
||||
plt.savefig(save_path, dpi=150, bbox_inches='tight')
|
||||
print(f"Total cost curves saved to: {save_path}")
|
||||
|
||||
return fig
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
df, results = main()
|
||||
|
||||
BIN
p1/total_cost_curves.png
Normal file
BIN
p1/total_cost_curves.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 65 KiB |
Reference in New Issue
Block a user