How can I show both top and bottom or left and right axes tick labels?

조회 수: 43 (최근 30일)
I would like to have axis tick labels on all sides of my plot. I would like the x-axis tick labels to be on the top and bottom of my plot and the y-axis tick labels to be on the left and right of my plot.
Turning the axes border on (with "box on" or by setting the axes 'Box' property to 'on') displays ticks on all sides, but not the corresponding tick labels.
Changing the 'XAxisLocation' or 'YAxisLocation' properties of the axes only toggle the labels, it does not allow me to have left and right or top and bottom labels.

채택된 답변

MathWorks Support Team
MathWorks Support Team 2013년 2월 11일
The ability to specify top and bottom or left and right positions for the axes tick labels is not available in MATLAB.
To work around this issue you can add a transparent axes to your plot and specify the 'XAxisLocation' property as 'top' and the 'YAxisLocation' property as 'right', as shown in the following code:
plot(1:10)
box off
axes('xlim', [1 10], 'ylim', [1 10], 'color', 'none', 'YAxisLocation', 'right', 'XAxisLocation', 'top')
  댓글 수: 1
Star Strider
Star Strider 2018년 8월 9일
See: XAxisLocation (link) and YAxisLocation (link).
These are relatively recent (I do not remember when they were added), so older versions of MATLAB may not have them. If yours does not, look in the File Exchange.

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

추가 답변 (0개)

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by