Borrar filtros
Borrar filtros

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

64 visualizaciones (últimos 30 días)
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 comentario
weijie.zhu
weijie.zhu el 30 de Nov. de 2023
Editada: weijie.zhu el 30 de Nov. de 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'};

Iniciar sesión para comentar.

Respuesta aceptada

Dyuman Joshi
Dyuman Joshi el 30 de Nov. de 2023
Editada: Dyuman Joshi el 30 de Nov. de 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;

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by