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

65 visualizaciones (últimos 30 días)
Benjamin
Benjamin el 23 de Jul. de 2020
Respondida: Star Strider el 23 de Jul. de 2020
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.

Respuestas (1)

Star Strider
Star Strider el 23 de Jul. de 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.
.

Community Treasure Hunt

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

Start Hunting!

Translated by