File Exchange

image thumbnail

Plot Confusion Matrix

version (56.6 KB) by Vahe Tshitoyan
Plots a colour-coded confusion matrix.


Updated 14 Jun 2018

View Version History

GitHub view license on GitHub

An alternative to plotconfusion from the Neural Network Toolbox.
plotConfMat(confmat, labels)

Cite As

Vahe Tshitoyan (2020). Plot Confusion Matrix (, GitHub. Retrieved .

Comments and Ratings (31)

Sarun Apichontrakul

Thank you for your work, however, according to confusionmat (I assume the input is generated by this function)
Shouldn't your labels for 'Output class (Predicted)' and 'Target class (Actual)' be swapped? Arent they on the wrong axes?

hanadi abbas

hatem barhoom

Andres Moran Duran

Thanks you

Soumitra Mehrotra

Elhassan Mohamed

Amol Nikam

husam janahi

Andries Meintjes

Rupert Thomas

David Franco



Victor Lopes

Hamza Fadhel

Thank you so much

Vahe Tshitoyan

Thanks for your feedback. You can change gray on line 41 in plotConfMat.m to the colormap of your choice.

David Franco

Is there a way to change the colors?

Mohd Faid Yahya



Cygnus Sphinx

Pierre Lonfat

Actually how do I save that as a figure please ?

Pierre Lonfat

Canberk Suat Gurel

Cheikh Latyr FALL

Ruba Alomari


Aris Fergadis


Hi, Vahe Tshitoyan

Nice work, maybe can add some more description for ease of usage. For example.

% Find the confusionmat matrix first
[C,order] = confusionmat(TestResults,PredictionResults)
% Then, plot
plotConfMat(C) plots the confmat with integers 1 to n as class labels
plotConfMat(C, order) plots the confmat with the specified labels


MATLAB Release Compatibility
Created with R2015b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!