How to change axis label position on a figure in MATLAB?

65 次查看(过去 30 天)
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.'
Thank you.

回答(1 个)

Star Strider
Star Strider 2020-7-23
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.
.

类别

Help CenterFile Exchange 中查找有关 Axis Labels 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by