Reputation: 955
When using the boxplot
command from Statistics toolbox, the axes properties change in a strange way. For example, one gets
XTick = [] XTickLabel = XTickLabelMode = manual XTickMode = manual
What is happening to the axes and how one can rename the labels, and/or drop some of the ticks?
Upvotes: 2
Views: 10612
Reputation: 1
Thank you, Sam Roberts, that was helpful.
I wrote the following to remove group labels based on this advice. However, it removes ALL the labels, including axis and data tips. There doesn't seem to be a way to remove a label on an axis but leave it on a data tip.
m = get(get(get(figH,'Children'),'Children'),'Children');
for ii = 1:numel(m)
if(strcmp(get(m(ii),'Type'),'text'))
set(m(ii),'String', '');
end
end
The variable figH is the handle to your figure. You can also try gcf if the boxplot is the active figure handle.
Upvotes: 0
Reputation: 321
Try this:
xtix = {'A','B','C'}; % Your labels
xtixloc = [1 2 3]; % Your label locations
set(gca,'XTickMode','auto','XTickLabel',xtix,'XTick',xtixloc);
For some reasons resetting XTickMode to auto seemed to be key.
Upvotes: 3
Reputation: 24127
Try calling boxplot
using the optional labels
parameter.
Edit - further information about what boxplot
actually does.
boxplot
does some complicated stuff - type edit boxplot
to take a look through the code, and you'll see it's a very long and intricate function. Basically it makes a blank axis with no axis labels, which is why you're seeing empty values for XTick
etc. Then it makes the boxplot elements out of individual lines, and it simulates fake axis labels by adding text elements. You can find them and modify them directly by plotting into a figure f
, then getting the Children
of f
, then iterating through to get their Children
. Eventually you'll find text elements with the label names.
Upvotes: 5