How can you shift the position of x axis labels?

62 ビュー (過去 30 日間)
L'O.G.
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'});
figure
scatter(xc,rand(5,size(xc,2)), 'filled')
colormap(turbo)
Ax = gca;
xtl = get(Ax,'XTickLabel');
set(Ax,'XTickLabel',[])
yl = ylim;
text(1:numel(xtl), ones(size(xtl))*(yl(1)-0.025*diff(yl)), xtl, 'Horiz','center', 'Vert','top', 'Rotation',30)
.
  2 件のコメント
L'O.G.
L'O.G. 2023 年 1 月 23 日
Thank you so much
Star Strider
Star Strider 2023 年 1 月 23 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by