MATLAB: Can I change the properties of the confusion matrix plot like axes labels and tick labels

Statistics and Machine Learning Toolbox

Can I change the properties of the confusion matrix plot like axes labels and tick labels?
For example, change the axes labels from "output" to "predicted", "target" to "actual", and change the tick labels from "2" to "0".

Best Answer

You can change the properties of the confusion matrix plot by accessing the figure handle, and axes handle properties of the plot. For example:
>> [x,t] = cancer_dataset;
>> net = patternnet(10);
>> net = train(net,x,t);
>> y = net(x);
>> plotconfusion(t,y)
>> fh = gcf % access the figure handle for the confusion matrix plot
>> ah = fh.Children(2) % access the corresponding axes handle
>> ah.XTickLabel{2} = 0 % change the tick labels
>> ah.YTickLabel{2} = 0
>> ah.XLabel.String = 'Actual' % change the axes labels
>> ah.YLabel.String = 'Predicted'