How can you shift the position of x axis labels?

조회 수: 13 (최근 30일)
L'O.G. . 2023년 1월 22일
댓글: Star Strider . 2023년 1월 23일
I can generate a scatter plot with the x axis labels of type categorical or string. When I rotate them slightly, I would like the end of the label to line up with the tick mark on the x axis, which is not currently the case. How can I do this?

채택된 답변

Star Strider
Star Strider 2023년 1월 23일
They’re probably text objects, however it’s not possible to access their properties. The only way to change them is to get them, delete them frm the axes, and use the text function to put them where you want them by setting the 'HorizontalAlignment'. 'VerticalAlignment', and other properties.
xc = categorical({'A1','A2','A3','A4','A5'});
scatter(xc,rand(5,size(xc,2)), 'filled')
Ax = gca;
xtl = get(Ax,'XTickLabel');
yl = ylim;
text(1:numel(xtl), ones(size(xtl))*(yl(1)-0.025*diff(yl)), xtl, 'Horiz','center', 'Vert','top', 'Rotation',30)

추가 답변 (0개)


Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기




Community Treasure Hunt

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

Start Hunting!

Translated by