Effacer les filtres
Effacer les filtres

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

64 vues (au cours des 30 derniers jours)
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 commentaire
weijie.zhu
weijie.zhu le 30 Nov 2023
Modifié(e) : weijie.zhu le 30 Nov 2023
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'};

Connectez-vous pour commenter.

Réponse acceptée

Dyuman Joshi
Dyuman Joshi le 30 Nov 2023
Modifié(e) : Dyuman Joshi le 30 Nov 2023
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;

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by