Rotate x axis labels boxplot Matlab 2015

30 ビュー (過去 30 日間)
Katherine Beaulieu
Katherine Beaulieu 2015 年 7 月 14 日
コメント済み: Katherine Beaulieu 2015 年 7 月 15 日
Hi there, I am trying to rotate labels on my boxplot but the code I am using doesn't seem to work on the 2015 version of Matlab. For example, the code I am using looks like this:
hA = boxplot(data,'Labels',names);
hb = findobj(parentFig,'Type','hggroup');
fontSize = 10;
rotation = 90;
text_h = findobj(hB,'Type','text');
for cnt = 1:length(text_h)
set(text_h(cnt), 'FontSize',fontSize,...
'Rotation',rotation,...
'String',names{length(names)-cnt+1},...
'HorizontalAlignment','right',...
'VerticalAlignment','middle');
end
Is there something I am not doing right?

採用された回答

Mike Garrity
Mike Garrity 2015 年 7 月 14 日
As of R2014b, it is a lot simpler:
boxplot(data,'Labels',names);
set(gca,'FontSize',10,'XTickLabelRotation',90)
  1 件のコメント
Katherine Beaulieu
Katherine Beaulieu 2015 年 7 月 15 日
Thanks Mike that worked perfectly:)

サインインしてコメントする。

その他の回答 (1 件)

Muthu Annamalai
Muthu Annamalai 2015 年 7 月 14 日
I don't know how to rotate the lables, even though using the
graphObj = gca
disp( graphObj.XLabel.Rotation )
allows you to set/get the rotation angles for the labels in your current plot.
I did see documentation for adding text to a chart/graph and rotate the text (specify angle in degrees)
text(45,45,5,'fuubar','Rotation',45)
HTH

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by