function [fig] = plotCM(cm,figureTitle)
    imagesc(squeeze(mean(cm,1)))
    colorbar();
    fig=gcf;
    axes =gca;
    if size(cm,2)==5
        axes.YAxis.TickLabels={'Rest','1','2','3','4'};
        axes.YAxis.TickValues=[1,2,3,4,5];
        axes.XAxis.TickLabels={'Rest','1','2','3','4'};
        axes.XAxis.TickValues=[1,2,3,4,5];
    elseif size(cm,2)==4
        axes.YAxis.TickLabels={'1','2','3','4'};
        axes.YAxis.TickValues=[1,2,3,4];
        axes.XAxis.TickLabels={'1','2','3','4'};
        axes.XAxis.TickValues=[1,2,3,4];
    else
        error('CM has neither 5 nor 4 entries - change plotCM to match your needs')
    end
    xlabel('classified as')
    ylabel('actual class')
    title(figureTitle)
end