![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/354218/image.png)
change location of y tick labels to the left or right of y axis
44 ビュー (過去 30 日間)
古いコメントを表示
Hello,
My y-axis is located at the origin for my hbar graph. The ytick labels are to the right of the y axis and I want to move them to the left. Is this possible?
Thanks.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/354188/image.png)
2 件のコメント
S. Walter
2020 年 8 月 31 日
編集済み: S. Walter
2020 年 8 月 31 日
I can't consistently reproduce the effect but if I try this:
b = barh(randn(10,1));
ax = gca;
ax.YAxisLocation = 'origin';
The marks appear on the left side:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/354218/image.png)
However, sometimes, it moves it to the labels to the right side so it doesn't appear to be very robust.
The other method you could try is to use a text object.
b = barh(randn(10,1));
ax = gca;
ax.YAxisLocation = 'origin';
ax.YTickLabel =[];
for i = 1 :1 : 10
text(0,i,num2str(i),'HorizontalAlignment','right');
end
採用された回答
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Axis Labels についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!