Show multiple axes all around image?

조회 수: 3 (최근 30일)
Roger Breton
Roger Breton . 2022년 1월 9일
댓글: Roger Breton . 2022년 1월 11일
Currently, I get this result :
1) Would it possible to have the 'axes' show all around the image? I'd like to experiment with horizontal scales showing above and below the image, and with vertical scales showing on both the left and right hand side of the image, if that is possible? I did not see any property to do this in axes properties.
2) Is it possible to show the '0' coordinates on the right hand side the the horizontal axes?
3) Is there a way to control how far away Labels appear from the image? Say, at the bottom?

채택된 답변

DGM 2022년 1월 10일
For a single axes, you can only have one set of tick labels per axis. The workaround is the creation of an empty axes to provide the other labels. The problem is making sure the two axes stay coincident. This should be a start, but it's probably not the end.
A = imread('peppers.png');
s = size(A);
axis equal
xlim([0 s(2)])
ylim([0 s(1)])
hax = gca;
% overlay empty axes
axis equal
xlim([0 s(2)])
ylim([0 s(1)])
xticklabels(flipud(xticklabels)) % flip ticklabel direction
% move xlabel
axes(hax); % switch back to first axes
hl = xlabel('dinner''s ready');
hl.Position(2) = hl.Position(2)+20; % this is in data units!
The web-figure really wants to cut that xlabel off, but in practice, you'll have to manage the axes position within the figure such that there are sufficient margins to move the xlabel away from the axes.
Regarding #2, note that only the label vector is being flipped. The coordinate space is not. If you use any sort of tool like the datatip tool or impixelinfo(), the coordinates will not agree with the labels. So while it can be done, I don't really think it's a good idea. You can set the 'xdir' property of both axes to 'reverse, which will reverse the labels, the ticks, and the image. That way, they all correspond -- but I assume you don't want the image flipped. I don't see the reason to do either.
Regarding #3, if you wanted instead to move the xticklabel position, I don't know if that's possible. There might be some other workaround, but I don't have one off the top of my head.
  댓글 수: 1
Roger Breton
Roger Breton 2022년 1월 11일
I suppressed the 'flipud(xticklabels)'. This is perfect :
Specifying the xlim([0 s(2)]) from 0 to the horitontal size of the image got the axis tick starting at the 0 mark. Great!
Thank you so much for your kind help!!!

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

추가 답변 (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