필터 지우기
필터 지우기

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