MATLAB: Is there any way to have labels in color for boxplots

boxplotcolorful fontlabels

It seems that boxplot function doesn't accept TeX Markup to give a specific color to labels of boxplot.
Any idea to give a color to a label using boxplot function?
boxplot([1 2 3 4], 'labels', {'a'}); % make 'a' red

Best Answer

They're just XTickLabel values; set as desired as with any other axes.
For some reason TMW hasn't made a color property for them (yet); is a worthwhile extension request.
boxplot([1 2 3 4], 'labels', {'a'});
hAx=gca;
hAx.XAxis.TickLabelInterpreter='tex'; % make sure interpreter set
hAx.XTickLabel(1)={['\color{red}' hAx.XTickLabel{1}]}; % make 'a' red
Or, of course, you can embed the TeX string in the call if you create the axes first to set the 'Interpreter' property and if boxplot doesn't clear it internally (that I don't know, didn't test).