MATLAB: How to rotate the X-axis tick labels and place an X-label on the plot after R2016b

MATLAB

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.

Best Answer

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:
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: