How to change axis label position on a figure in MATLAB?
79 views (last 30 days)
Show older comments
Hello
Dear all,
In a scatter plot I changed the ax.XAxisLocation and ax.YAxisLocation to be 'origin', however, I do not want the x-axis and y-axis label be inside the plot. I want to move it outside (like the picture below) and also rotate it if necessary. I appreciate it you help me.'
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/336217/image.png)
Thank you.
0 Comments
Answers (1)
Star Strider
on 23 Jul 2020
It is not possible to re-position them, so use text objects to create the axis labels in the appropriate positions.
Try something like this example:
figure
scatter(randn(1,50), randn(1,50))
set(gca, 'XAxisLocation','origin', 'YAxisLocation','origin')
xl = xlim;
yl = ylim;
text(min(xl), 0, 'Prediction of proposed probabalistic model', 'Rotation',90, 'VerticalAlignment','bottom', 'HorizontalAlignment','center')
text(0, min(yl), 'Experimental data', 'VerticalAlignment','top', 'HorizontalAlignment','center')
It will likely be necessary to change only the string objects (desired axis labels) in this code.
It may be necessary to make a few other adjustments to get the desired appearance.
.
0 Comments
See Also
Categories
Find more on Axis Labels in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!