change location of y tick labels to the left or right of y axis

조회 수: 35 (최근 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.
  댓글 수: 2
S. Walter
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:
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
Emily Pendleton
Emily Pendleton 2020년 9월 1일
Thank you! Your second solution works for me. Much appreciated!

댓글을 달려면 로그인하십시오.

채택된 답변

Emily Pendleton
Emily Pendleton 2020년 9월 1일
this question has been answered

추가 답변 (0개)

카테고리

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