Plot labels histogram colors (#3192)

pull/3193/head
Glenn Jocher 2021-05-17 11:44:22 +02:00 committed by GitHub
parent b133baa336
commit ae53f50ae7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -299,7 +299,8 @@ def plot_labels(labels, names=(), save_dir=Path(''), loggers=None):
# matplotlib labels
matplotlib.use('svg') # faster
ax = plt.subplots(2, 2, figsize=(8, 8), tight_layout=True)[1].ravel()
ax[0].hist(c, bins=np.linspace(0, nc, nc + 1) - 0.5, rwidth=0.8)
y = ax[0].hist(c, bins=np.linspace(0, nc, nc + 1) - 0.5, rwidth=0.8)
[y[2].patches[i].set_color([x / 255 for x in colors(i)]) for i in range(nc)] # update colors
ax[0].set_ylabel('instances')
if 0 < len(names) < 30:
ax[0].set_xticks(range(len(names)))