MATLAB: How to add xlabel and ylabel to the individual subplots of plotmatrix

MATLAB

I would like to label each of the rows and columns of the plotmatrix with the variable names used to create it.

Best Answer

  • It is possible to do this by getting handles to the individual axes and labeling them manually with the xlabel and ylabel functions.
    X = rand(20,3);
    [~,ax] = plotmatrix(X);
    ylabel(ax(1,1),'var1')
    ylabel(ax(2,1),'var2')
    ylabel(ax(3,1),'var3')
    xlabel(ax(3,1),'var1')
    xlabel(ax(3,2),'var2')
    xlabel(ax(3,3),'var3')