polarrcnn-thesis/thesis_figure/anchor_num_method.py
2024-10-30 02:51:17 +08:00

50 lines
2.1 KiB
Python

import matplotlib.pyplot as plt
import matplotlib as mpl
# 设置全局字体为 Times New Roman
mpl.rcParams['font.family'] = 'Times New Roman'
mpl.rcParams['font.serif'] = ['Times New Roman']
mpl.rcParams['axes.titlesize'] = 14
mpl.rcParams['axes.labelsize'] = 12
mpl.rcParams['xtick.labelsize'] = 12
mpl.rcParams['ytick.labelsize'] = 12
mpl.rcParams['legend.fontsize'] = 12
# 定义数据
data = {
'LaneATT (2021)': {'x': [1000, 1000, 1000], 'y': [75.09, 76.68, 77.02], 'sizes': [40*2.5, 80*2.5, 180*2.5], 'color': 'magenta', 'marker': 'H'},
'CLRNet (2022)': {'x': [192, 192, 192, 192], 'y': [79.58, 79.73, 80.13, 80.47], 'sizes': [20*2.5, 40*2.5, 80*2.5, 180*2.5], 'color': 'orange', 'marker': 'p'},
'CLRerNet (2023)': {'x': [192, 192, 192], 'y': [80.76, 80.91, 81.12], 'sizes': [40*2.5, 80*2.5, 180*2.5], 'color': 'orangered', 'marker': 'p'},
'ADNet (2023)': {'x': [64, 64], 'y': [77.56, 78.94], 'sizes': [80*2.5, 180*2.5], 'color': 'green', 'marker': 'v'},
'SRLane (2024)': {'x': [40], 'y': [79.73], 'sizes': [180*2.5], 'color': 'red', 'marker': '*'},
'Sparse Laneformer (2024)': {'x': [20, 20, 20], 'y': [76.55, 77.77, 77.83], 'sizes': [40*2.5, 80*2.5, 180*2.5], 'color': 'purple', 'marker': '^'},
'Polar R-CNN (Ours)': {'x': [20, 20, 20, 20], 'y': [80.81, 80.92, 81.34, 81.49], 'sizes': [20*2.5, 40*2.5, 80*2.5, 180*2.5], 'color': 'blue', 'marker': 'o'},
}
# 定义统一的标记大小
legend_marker_size = 100
# 绘制数据点
for label, props in data.items():
plt.scatter(
props['x'], props['y'],
s=props['sizes'],
alpha=0.5,
c=props['color'],
marker=props['marker'],
edgecolors='w',
linewidth=0.5,
label=label
)
# 设置标题和标签
plt.grid(True, linestyle='-', alpha=0.5)
plt.xlabel('Anchor Number', fontsize=16)
plt.ylabel('F1@50 (%)', fontsize=16)
# 添加图例,并调整图例中的标记大小
legend = plt.legend(loc="best")
for handle in legend.legend_handles:
handle._sizes = [legend_marker_size]
plt.savefig('anchor_num_method.png', dpi=300)
plt.show()