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

Function plot_without_labels

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

Source from the content-addressed store, hash-verified

318
319
320def plot_without_labels(save_path, lowDWeights, labels, camid):
321 import matplotlib.pyplot as plt
322 padding_rate = 0.1
323 plt.cla()
324 X, Y = lowDWeights[:, 0], lowDWeights[:, 1]
325 unique = np.unique(labels)
326 num_type_color = len(unique)
327 cmap = get_cmap(num_type_color)
328 colors = {l: cmap(i) for i, l in enumerate(unique)}
329 colors = sns.color_palette("viridis", n_colors=num_type_color)
330
331 for x, y, s, cam in zip(X, Y, labels, camid):
332 if cam == 9:
333 plt.text(x, y, ' ', fontsize=3,
334 ha='center', va='center', # 水平居中,垂直居中
335 bbox=dict(boxstyle='circle', # 圆圈
336 ec=colors[s], # 边框颜色
337 fc=colors[s] # 填充颜色
338 ))
339 elif cam == 8:
340 plt.text(x, y, ' ', fontsize=3,
341 ha='center', va='center', # 水平居中,垂直居中
342 bbox=dict(boxstyle='square', # 圆圈
343 ec=colors[s], # 边框颜色
344 fc=colors[s] # 填充颜色
345 ))
346 elif cam == 7:
347 plt.text(x, y, ' ', fontsize=5,
348 ha='center', va='center', # 水平居中,垂直居中
349 bbox=dict(boxstyle='circle', # 圆圈
350 ec=colors[s], # 边框颜色
351 fc=colors[s] # 填充颜色
352 ))
353 elif cam == 3 or cam == 6:
354 plt.text(x, y, ' ', fontsize=1,
355 ha='center', va='center', # 水平居中,垂直居中
356 bbox=dict(boxstyle='circle', # 圆圈
357 ec=colors[s], # 边框颜色
358 fc=colors[s] # 填充颜色
359 ))
360 elif cam == 0:
361 plt.text(x, y, ' ', fontsize=1,
362 ha='center', va='center', # 水平居中,垂直居中
363 bbox=dict(boxstyle='circle', # 圆圈
364 ec=colors[s], # 边框颜色
365 fc=colors[s] # 填充颜色
366 ))
367 else:
368 plt.text(x, y, ' ', fontsize=1,
369 ha='center', va='center', # 水平居中,垂直居中
370 bbox=dict(boxstyle='square', #
371 ec=colors[s], # 边框颜色
372 fc=colors[s] # 填充颜色
373 ))
374 plt.xlim(X.min() - padding_rate * X.min(), X.max() + padding_rate * X.max())
375 plt.ylim(Y.min() - padding_rate * Y.min(), Y.max() + padding_rate * Y.max())
376 # plt.xlim(X.min(), X.max())
377 # plt.ylim(Y.min(), Y.max())

Callers

nothing calls this directly

Calls 1

get_cmapFunction · 0.85

Tested by

no test coverage detected