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

조회 수: 107 (최근 30일)
Benjamin
Benjamin 2020년 7월 23일
답변: Star Strider 2020년 7월 23일
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