MCPcopy Create free account
hub / github.com/TPCD/DCCL / plot_with_labels

Function plot_with_labels

project_utils/visualization_utils.py:28–92  ·  view source on GitHub ↗
(save_path, lowDWeights, labels, camid)

Source from the content-addressed store, hash-verified

26
27
28def plot_with_labels(save_path, lowDWeights, labels, camid):
29 import matplotlib.pyplot as plt
30 padding_rate = 0.1
31 plt.cla()
32 X, Y = lowDWeights[:, 0], lowDWeights[:, 1]
33 unique = np.unique(labels)
34 num_type_color = len(unique)
35 cmap = get_cmap(num_type_color)
36 label2color_dict = {l: cmap(i) for i, l in enumerate(unique)}
37
38 for x, y, s, cam in zip(X, Y, labels, camid):
39 if cam == 9:
40 plt.text(x, y, s, fontsize=3,
41 ha='center', va='center', # 水平居中,垂直居中
42 bbox=dict(boxstyle='circle', # 圆圈
43 ec=colors[s], # 边框颜色
44 fc=colors[s] # 填充颜色
45 ))
46 elif cam == 8:
47 plt.text(x, y, s, fontsize=3,
48 ha='center', va='center', # 水平居中,垂直居中
49 bbox=dict(boxstyle='square', # 圆圈
50 ec=colors[s], # 边框颜色
51 fc=colors[s] # 填充颜色
52 ))
53 elif cam == 7:
54 plt.text(x, y, s, fontsize=5,
55 ha='center', va='center', # 水平居中,垂直居中
56 bbox=dict(boxstyle='circle', # 圆圈
57 ec=colors[s], # 边框颜色
58 fc=colors[s] # 填充颜色
59 ))
60 elif cam == 3 or cam == 6:
61 plt.text(x, y, s, fontsize=1,
62 ha='center', va='center', # 水平居中,垂直居中
63 bbox=dict(boxstyle='circle', # 圆圈
64 ec=colors[s], # 边框颜色
65 fc=colors[s] # 填充颜色
66 ))
67 elif cam == 0:
68 plt.text(x, y, s, fontsize=1,
69 ha='center', va='center', # 水平居中,垂直居中
70 bbox=dict(boxstyle='circle', # 圆圈
71 ec=colors[s], # 边框颜色
72 fc=colors[s] # 填充颜色
73 ))
74 else:
75 plt.text(x, y, s, fontsize=1,
76 ha='center', va='center', # 水平居中,垂直居中
77 bbox=dict(boxstyle='square', #
78 ec=colors[s], # 边框颜色
79 fc=colors[s] # 填充颜色
80 ))
81 # plt.xlim(X.min()-padding_rate*X.min(), X.max()+padding_rate*X.max())
82 # plt.ylim(Y.min()-padding_rate*Y.min(), Y.max()+padding_rate*Y.max())
83 plt.xlim(X.min(), X.max())
84 plt.ylim(Y.min(), Y.max())
85 plt.axis('off')

Callers

nothing calls this directly

Calls 1

get_cmapFunction · 0.85

Tested by

no test coverage detected