import matplotlib.pyplot as plt import numpy as np import matplotlib.font_manager as fm from matplotlib import font_manager, rcParams font_path = "/nfs/ywang29/GmNet/times.ttf" # 按实际路径修改 font_manager.fontManager.addfont(font_path) rcParams['font.family'] = 'Times New Roman' # 示例数据 x = np.arange(0, 10) * 500 diffusionrf = [26.59, 27.26, 28.09, 27.98, 26.93, 24.24, 26.77, 28.66, 27.7, 28.59] videoalign = [26.59, 26.32, 27.2, 27.41, 27.29, 26.23, 26.98, 24.43, 23.85, 24.02] pickscore = [26.59, 24.32, 20.62, 23.88, 24.45, 18.17, 22.01,19.7, 21.83, 18.762] base = [26.59 for i in range(len(x))] plt.figure(figsize=(7, 4)) # 三条折线,三角形标记 plt.plot(x, diffusionrf, marker='^', linestyle='-', linewidth=2, markersize=8, label='Diffusion-DRF') plt.plot(x, videoalign, marker='^', linestyle='-', linewidth=2, markersize=8, label='VideoAlign') plt.plot(x, pickscore, marker='^', linestyle='-', linewidth=2, markersize=8, label='PickScore') plt.plot(x, base, linestyle='--', linewidth=2, markersize=8, color='gray', label='Base Model') # 添加标题与坐标轴标签 # plt.title("", fontsize=13) plt.xlabel("Training Steps", fontsize=18) plt.ylabel("Controllability Score", fontsize=18) # 添加网格 plt.grid(True, linestyle='--', alpha=0.6) # 图例 plt.legend() # 自动紧凑布局 plt.tight_layout() # 保存为 PDF 文件 output_path = "/nfs/ywang29/Reward_finetuning/VideoX-Fun/plots/learning_dyn.pdf" plt.savefig(output_path, bbox_inches="tight", format="pdf", dpi=300) output_path = "/nfs/ywang29/Reward_finetuning/VideoX-Fun/plots/learning_dyn.png" plt.savefig(output_path, bbox_inches="tight", format="png", dpi=300) print(f"✅ 图已保存为 {output_path}") # # 显示图形 # plt.show()