Fix `plot_labels()` colored histogram bug (#6574)
Browse files* Fix `plot_labels()` colored histogram bug
* Cleanup
- utils/plots.py +4 -1
utils/plots.py
CHANGED
@@ -340,7 +340,10 @@ def plot_labels(labels, names=(), save_dir=Path('')):
|
|
340 |
matplotlib.use('svg') # faster
|
341 |
ax = plt.subplots(2, 2, figsize=(8, 8), tight_layout=True)[1].ravel()
|
342 |
y = ax[0].hist(c, bins=np.linspace(0, nc, nc + 1) - 0.5, rwidth=0.8)
|
343 |
-
|
|
|
|
|
|
|
344 |
ax[0].set_ylabel('instances')
|
345 |
if 0 < len(names) < 30:
|
346 |
ax[0].set_xticks(range(len(names)))
|
|
|
340 |
matplotlib.use('svg') # faster
|
341 |
ax = plt.subplots(2, 2, figsize=(8, 8), tight_layout=True)[1].ravel()
|
342 |
y = ax[0].hist(c, bins=np.linspace(0, nc, nc + 1) - 0.5, rwidth=0.8)
|
343 |
+
try: # color histogram bars by class
|
344 |
+
[y[2].patches[i].set_color([x / 255 for x in colors(i)]) for i in range(nc)] # known issue #3195
|
345 |
+
except Exception:
|
346 |
+
pass
|
347 |
ax[0].set_ylabel('instances')
|
348 |
if 0 < len(names) < 30:
|
349 |
ax[0].set_xticks(range(len(names)))
|