DeCLIP-TPAMI / tools /plot_radarv2.3.py
xiaomoguhzz's picture
Add files using upload-large-folder tool
c50dde6 verified
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Patch, Wedge
import matplotlib.patheffects as PathEffects
# 数据
labels = [
'SN200_ap', 'SN200_head', 'SN200_tail',
'LV-VIS_val', 'LV-VIS_test', 'OVIS', 'YTVIS19','YTVIS21','BURST',
'REAL_AR', 'REAL_mIoU', 'TOYL_AR', 'TOYL_mIoU'
]
declip_value = [26.4, 28.2, 27.7,
37.7,30.9,29.3,54.8,49.1,10.1,
37.6, 72.2, 32.6, 68.7]
Open3DIS_value = [23.7, 21.2, 21.8,
0, 0, 0, 0,0,0,
0, 0, 0, 0,]
CLIP_VIS_value = [0, 0, 0,
32.2,25.3,18.5,42.1,37.9,8.3,
0, 0, 0, 0]
oryon_value = [0, 0, 0,
0, 0, 0, 0, 0, 0,
32.2,66.5,30.3,68.1]
declip_target = 40
# 自动计算归一化值
def normalize_values(target, base_values, method_values):
normalized = []
for base, value in zip(base_values, method_values):
if base == 0 or value == 0:
normalized.append(0)
else:
normalized.append((value / base) * target)
return normalized
# 颜色设置
declip_color = '#6c4f3d' # 调深原来的颜色
Open3DIS_color = '#b04fc0' # 洋红紫
CLIP_VIS_color = '#ffc145' # 琥珀黄
oryon_color = '#3de1b5' # 青柠绿
declip = normalize_values(declip_target, declip_value, declip_value)
Open3DIS = normalize_values(declip_target, declip_value, Open3DIS_value)
CLIP_VIS = normalize_values(declip_target, declip_value, CLIP_VIS_value)
oryon = normalize_values(declip_target, declip_value, oryon_value)
# 均匀分布角度
num_labels = len(labels)
angles = np.linspace(0, 2 * np.pi, num_labels, endpoint=False).tolist()
angles += angles[:1] # 首尾相连
# 数据补充,首尾相连
declip = np.concatenate((declip, [declip[0]]))
Open3DIS = np.concatenate((Open3DIS, [Open3DIS[0]]))
CLIP_VIS = np.concatenate((CLIP_VIS, [CLIP_VIS[0]]))
oryon = np.concatenate((oryon, [oryon[0]]))
fig, ax = plt.subplots(figsize=(8, 8), subplot_kw=dict(polar=True))
ax.set_ylim(0, 43)
# 主线与对比线条
ax.plot(angles, declip, color=declip_color, linewidth=3.2, linestyle='solid', zorder=3,
path_effects=[PathEffects.withStroke(linewidth=6, foreground="white")])
ax.plot(angles, Open3DIS, color=Open3DIS_color, linewidth=2.6, linestyle='dashed', zorder=2) # 粗细调为2.6
ax.plot(angles, CLIP_VIS, color=CLIP_VIS_color, linewidth=2.6, linestyle='dashed', zorder=2) # 粗细调为2.6
ax.plot(angles, oryon, color=oryon_color, linewidth=2.6, linestyle='dashed', zorder=2) # 粗细调为2.6
ax.fill(angles, Open3DIS, color=Open3DIS_color, alpha=0.05, zorder=1)
ax.fill(angles, CLIP_VIS, color=CLIP_VIS_color, alpha=0.05, zorder=1)
ax.fill(angles, oryon, color=oryon_color, alpha=0.05, zorder=1)
# 散点
ax.scatter(angles, declip, facecolors=declip_color, s=65, zorder=4, alpha=0.95, linewidth=1, edgecolors='white')
ax.scatter(angles, Open3DIS, facecolors=Open3DIS_color, s=55, zorder=3, alpha=0.9, linewidth=0.6, edgecolors='white')
ax.scatter(angles, CLIP_VIS, facecolors=CLIP_VIS_color, s=55, zorder=3, alpha=0.9, linewidth=0.6, edgecolors='white')
ax.scatter(angles, oryon, facecolors=oryon_color, s=55, zorder=3, alpha=0.9, linewidth=0.6, edgecolors='white')
# 极径线、主圆线
theta = np.linspace(0, 2 * np.pi, 500)
ax.plot(theta, [43] * len(theta), color='black', linestyle='-', linewidth=1.5, alpha=0.7, zorder=0)
ax.set_yticks([10, 20, 30, 40])
ax.set_yticklabels([]) # 不显示极径标签
# DeCLIP关键点标数值(只标非0点,白边防遮挡)
for idx, (angle, val, raw_val) in enumerate(zip(angles, declip, declip_value + [declip_value[0]])):
if raw_val > 0:
if idx == 0 or idx == len(declip) - 1:
txt = ax.text(angle+0.1, val, f'{raw_val:.1f}', color=declip_color, fontsize=12.5, fontweight='bold',
ha='center', va='center', zorder=5)
txt.set_path_effects([PathEffects.withStroke(linewidth=3, foreground="white")])
else:
txt = ax.text(angle, val, f'{raw_val:.1f}', color=declip_color, fontsize=12.5, fontweight='bold',
ha='center', va='center', zorder=5)
txt.set_path_effects([PathEffects.withStroke(linewidth=3, foreground="white")])
# 只显示自定义标签,不显示角度刻度
ax.set_xticks(angles[:-1]) # 只设置你的label角度
ax.set_xticklabels(labels, fontsize=13, fontweight='bold',rotation=30,
path_effects=[PathEffects.withStroke(linewidth=3, foreground="white")])
# 图例
legend_elements = [
Patch(facecolor=declip_color, edgecolor='white', label='DeCLIP (Ours)'),
Patch(facecolor=Open3DIS_color, edgecolor='white', label='Open3DIS (OV3DIS SOTA)'),
Patch(facecolor=CLIP_VIS_color, edgecolor='white', label='CLIP-VIS (OVVIS SOTA)'),
Patch(facecolor=oryon_color, edgecolor='white', label='Oryon (OV6DP SOTA)')]
ax.legend(
handles=legend_elements,
frameon=True,
fontsize=12,
loc='upper center',
bbox_to_anchor=(0.5, 1.16),
ncol=2,
framealpha=0.1,
borderaxespad=0.4,
handleheight=1.3
)
plt.tight_layout()
plt.savefig('radar_chart_extend.png', dpi=300, bbox_inches='tight', transparent=True)