Show multiple axes all around image?
조회 수: 3 (최근 30일)
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);
hax = gca;
% overlay empty axes
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.