tick marks in boxplot

close all
fh = figure(1);
boxplot(data,time,'colors','k','jitter',1,'medianstyle','line',...
'whisker',2,'symbol','k.');
set(gca,'xtick',1:length(time),'xticklabel',time);
hB=findobj(fh,'Type','hggroup');
hL=findobj(hB,'Type','text');
set(hL,'Rotation',30);
I use this code to produce box plot of my data. The code works fine except for the fact that it does not rotate the xtick labels, i.e. it seems to ignore the rotate command. However, if I comment out:
set(gca,'xtick',1:length(time),'xticklabel',time);
Then the xticks are rotated, but the tick marks disappear, why does it react in this manner?
I need to find a method which allows for the Xticks to appear and the Xtick labels to be rotated, I cant seem to find a method which allows for both of these to occur.

回答(1 个)

This should help..
close all
fh = figure(1);
boxplot(data,time,'colors','k','jitter',1,'medianstyle','line',...
'whisker',2,'symbol','k.');
hB=findobj(fh,'Type','hggroup');
hL=findobj(hB,'Type','text');
set(hL,'Rotation',30);
set(gca,'xtick',1:length(time));

4 个评论

This is the same as I had before, although in a different order. Either way, it doesn't seem to change the outcome, the ticks are present but the xticks are not rotated.
shows me the 'ticks' and the rotated labels.. http://postimage.org/image/tqjq82wld/
strange what could be the problem in my case then?
try restarting MATLAB.. FYI I'm on R2012a (not that it should make a difference)..

请先登录,再进行评论。

标签

提问:

2012-4-16

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by