Skip to content

Commit

Permalink
adjusted confusion matrix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
Cortys committed Feb 23, 2022
1 parent f52b63c commit 6ac98cd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/usgoc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def draw_graph(

def draw_confusion_matrix(m, labels, show=True):
fig, ax = plt.subplots()
ax.imshow(m)
ax.imshow(m, cmap="BuGn")
ax.set_xticks(np.arange(len(labels)))
ax.set_yticks(np.arange(len(labels)))
ax.set_xticklabels(labels)
Expand All @@ -191,7 +191,11 @@ def draw_confusion_matrix(m, labels, show=True):

for i in range(len(labels)):
for j in range(len(labels)):
ax.text(j, i, m[i, j], ha="center", va="center", color="w")
v = m[i, j]
color = "black" if v <= 60 else "w"
ax.text(
j, i, v, ha="center",
va="center", color=color)
fig.tight_layout()
if show:
plt.show()
Expand Down

0 comments on commit 6ac98cd

Please sign in to comment.