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
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);
image(A);
axis equal
xlim([0 s(2)])
ylim([0 s(1)])
xticklabels(flipud(xticklabels))
hax = gca;
% overlay empty axes
axes('color','none','XAxisLocation','top','YAxisLocation','right','ydir','reverse')
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 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by