如何用Python为含POD与Successratio的数据集绘制Performance Diagram
绘制匹配要求的Performance Diagram
数据集整理
先将你的结构化数据整理为便于使用的格式:
| Products | POD | Successratio |
|---|---|---|
| CPC | 0.85 | 0.40 |
| ARC | 0.74 | 0.34 |
| TAM | 0.65 | 0.28 |
| PER | 0.80 | 0.35 |
实现代码(Python + Matplotlib)
以下代码可生成标准的Performance Diagram,包含散点标注、CSI等值线、随机参考线、完美性能点等核心元素,完全匹配这类图表的通用示例样式:
import matplotlib.pyplot as plt import numpy as np # 加载数据集 products = ['CPC', 'ARC', 'TAM', 'PER'] pod = [0.85, 0.74, 0.65, 0.80] success_ratio = [0.40, 0.34, 0.28, 0.35] # 创建画布 fig, ax = plt.subplots(figsize=(8, 8)) # 绘制散点并标注产品名称 for p, po, sr in zip(products, pod, success_ratio): ax.scatter(sr, po, s=100, zorder=5) ax.text(sr + 0.01, po + 0.01, p, fontsize=12) # 绘制CSI等值线 sr_grid, pod_grid = np.meshgrid(np.linspace(0, 1, 100), np.linspace(0, 1, 100)) csi_values = [0.2, 0.4, 0.6, 0.8] for csi in csi_values: # CSI计算公式:CSI = (POD * SuccessRatio) / (POD + SuccessRatio - POD*SuccessRatio) contour = ax.contour(sr_grid, pod_grid, (pod_grid * sr_grid) / (pod_grid + sr_grid - pod_grid * sr_grid), levels=[csi], colors='gray', linestyles='--') ax.clabel(contour, inline=True, fontsize=10, fmt=f'CSI={csi}') # 绘制随机猜测参考线(POD = SuccessRatio) ax.plot([0, 1], [0, 1], color='red', linestyle=':', label='Random Guess') # 绘制完美性能标记点 ax.scatter(1, 1, s=150, marker='*', color='green', zorder=10) ax.text(0.95, 0.95, 'Perfect', fontsize=12, ha='right') # 设置坐标轴与样式 ax.set_xlim(0, 1) ax.set_ylim(0, 1) ax.set_xlabel('Success Ratio (Precision)', fontsize=12) ax.set_ylabel('Probability of Detection (POD)', fontsize=12) ax.set_title('Performance Diagram', fontsize=14) ax.grid(True, linestyle='-', alpha=0.3) ax.legend() plt.show()
自定义调整说明
- 若需匹配示例图的散点大小、标注位置,可修改
scatter的s参数和text的偏移值 - CSI等值线的数值、线型可通过修改
csi_values和linestyles参数调整 - 随机线、完美点的颜色、样式也可根据示例图需求直接修改对应参数
内容的提问来源于stack exchange,提问作者Fusi
相关产品推荐
相关产品推荐

