How to create line breaks in x-axis tick labels of a boxplot in MATLAB?

64 次查看(过去 30 天)
boxplot(rand(10,11))
ax=gca;
ax.Title.String='Points Scored by the Top 11 Scoring NBA Players in 2012';
ax.Subtitle.String='Each point is a game';
ax.XLim=[0,12];
ax.XTick=1:1:11;
ax.XTickLabel = {'Lebron\newlineJames', 'Deron\newlineWilliams', 'James\newlineHarden', ...
'Carmelo\newlineAnthony', 'Tony\newlineParker', 'Kyrie\newlineIrving', ...
'Stephen\newlineCurry', 'Russell\newlineWestbrook','Lamarcus\newlineAldridge','Kevin\newlineDurant','Kobe\newlineBryant'};
  1 个评论
weijie.zhu
weijie.zhu 2023-11-30
编辑:weijie.zhu 2023-11-30
ax=gca;
ax.Title.String='Points Scored by the Top 11 Scoring NBA Players in 2012';
ax.Subtitle.String='Each point is a game';
ax.XLim=[0,12];
ax.XTick=1:1:11;
ax.XTickLabel = {'Lebron\newlineJames', 'Deron\newlineWilliams', 'James\newlineHarden', ...
'Carmelo\newlineAnthony', 'Tony\newlineParker', 'Kyrie\newlineIrving', ...
'Stephen\newlineCurry', 'Russell\newlineWestbrook','Lamarcus\newlineAldridge','Kevin\newlineDurant','Kobe\newlineBryant'};

请先登录,再进行评论。

采纳的回答

Dyuman Joshi
Dyuman Joshi 2023-11-30
编辑:Dyuman Joshi 2023-11-30
Change the TickLabelInterpreter to 'tex'.
You can adjust the x-axis fontsize to avoid the overlapping among labels.
boxplot(rand(10,11))
ax=gca;
ax.Title.String='Points Scored by the Top 11 Scoring NBA Players in 2012';
ax.Subtitle.String='Each point is a game';
ax.XLim=[0,12];
ax.XTick=1:1:11;
ax.XTickLabel = {'Lebron\newlineJames', 'Deron\newlineWilliams', 'James\newlineHarden', ...
'Carmelo\newlineAnthony', 'Tony\newlineParker', 'Kyrie\newlineIrving', ...
'Stephen\newlineCurry', 'Russell\newlineWestbrook','Lamarcus\newlineAldridge','Kevin\newlineDurant','Kobe\newlineBryant'};
%Change the Tick label interpreter
ax.TickLabelInterpreter = 'tex';
%Adjust the x-axis font size
ax.XAxis.FontSize = 7;

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Axis Labels 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by