Skip to content
Snippets Groups Projects
Commit e1b64fe5 authored by Dennis Noll's avatar Dennis Noll
Browse files

[plotting] adaptive text coloring

parent 430cda33
No related branches found
No related tags found
No related merge requests found
......@@ -71,14 +71,16 @@ def figure_confusion_matrix(
tick_marks = np.arange(len(class_names))
plt.xticks(tick_marks, class_names, rotation=45)
plt.yticks(tick_marks, class_names)
half = (cm.max() + cm.min()) / 2
for i, j in itertools.product(range(cm.shape[0]), range(cm.shape[1])):
fontdict = {"color": "black" if cm[i, j] > half else "white"}
plt.text(
j,
i,
np.around(cm[i, j], decimals=2),
horizontalalignment="center",
size=7,
fontdict=fontdict,
)
plt.ylabel("True label" + " (normed)" * (normalize == "true"))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment