MATLAB: Is there a groot default for xlabel and ylabel HorizontalAlignment and VerticalAlignment

groot defaulthorizontal alignmentvertical alignmentxlabelylabel

I'm trying to do something global like
set(groot, 'DefaultXLabelVerticalAlignment', 'middle').
I looked through the entire groot 'factory' and saw nothing appropriate. I expressly don't want to have to set this everytime I call xlabel. Any ideas?

Best Answer

  • Finally, this piece of code works (R2016a). I put it in the header file that is called by all GUI programs in my suite:
    set(groot, 'DefaultAxesCreateFcn', @axisDefaultCreateFcn);
    function axisDefaultCreateFcn(hAx, ~)
    xl = get(hAx, 'XLabel');
    set(xl, 'VerticalAlignment', 'middle');
    end