MATLAB Answers

x-axis label adjustment (negative value)

19 views (last 30 days)
Sehoon Chang
Sehoon Chang on 19 Oct 2020
Edited: VBBV on 19 Oct 2020
dear advisors,
i am having difficulty finding out how to adjust the x-axis label.
As you may see in the figure below, my x-axis labels are clustered and the numbers aren't horizontally oriented.
In order to rearrange the x-axis labels, i have used 'xticks' and 'xticklabels'.
However, the result after applying 'xticks' and 'xticklabels' cuts the minus values of x-axis off.
set(gca, 'XLim',[-20 40], 'XTick', -10:5:30 , 'XTickLabel', -10:5:30);
What may be the problem, and how may i correct it?
Thanks.

Answers (1)

VBBV
VBBV on 19 Oct 2020
Edited: VBBV on 19 Oct 2020
Set it higher limits or explicitly
  1 Comment
VBBV
VBBV on 19 Oct 2020
Specify explicitly the xlim and ticks values in cell arrays
%if true
% code
% end
xlim([-15 40])
xticks(-15:5:40);
xticklabels({'-15','-10','-5','0','5','10','15','20','25','30','35','40'})

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by