How can I rotate my X-axis tick labels and place an X-label on my plot after R2016b?

5 views (last 30 days)
I want to replace the X-tick labels (XTickLabel) with strings and rotate them so that they are at an angle of 45 degrees to the axes. I would like to do this and still be able to place a X-label (xlabel) on my plot.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 12 Apr 2023
Edited: MathWorks Support Team on 12 Apr 2023
You can label the x-axis using the "xlabel" function. For example:
plot(1:10)
xlabel('My x-Axis Label Text')
For more information about "xlabel", see:
Run these command in MATLAB 2016b for documentation:
>> web(fullfile(docroot, 'matlab/ref/xlabel.html'))
Or,
for latest release documentation please refer to:
You can rotate the x-axis tick labels using the "xtickangle" function. For example:
xtickangle(45)
The "xtickangle" function was introduced in R2016b. If you are using R2014b through R2016a, you can rotate the labels by setting the XTickLabelRotation property of the Axes object. For example:
ax = gca;
ax.XTickLabelRotation = 45;
For more information about "xtickangle", see:
Run these command in MATLAB 2016b for documentation:
>> web(fullfile(docroot, 'matlab/ref/xtickangle.html'))
Or,
for latest release documentation please refer to:

More Answers (0)

Tags

No tags entered yet.

Products


Release

R2016b

Community Treasure Hunt

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

Start Hunting!