13

我想编辑正在显示的一系列图像中的轴。

这是我的图像的样子:

抛物线

如您所见,它从上到下的范围从 0 到大约 500。我可以反转吗?另外,我想镜像正在显示的图像,以便它从左到右开始......或者,如果可能的话,让轴从右到左显示。

4

4 回答 4

17

要反转轴,您可以将当前轴'XDir'的or'YDir'属性设置为:'reverse'

set(gca,'XDir','reverse');  %# This flips the x axis

请记住,以这种方式翻转轴也会翻转图中的所有内容。这可能不是您想要对 y 轴执行的操作。您可能只想翻转 y 轴标签,您可以通过'YTickLabel'以下方式修改属性来实现:

yLimits = get(gca,'YLim');  %# Get the y axis limits
yTicks = yLimits(2)-get(gca,'YTick');  %# Get the y axis tick values and
                                       %#   subtract them from the upper limit
set(gca,'YTickLabel',num2str(yTicks.'));  %'# Convert the tick values to strings
                                           %#   and update the y axis labels
于 2010-05-19T13:47:57.463 回答
2
Im = imread('onion.png');

Im = flipdim(Im ,1); % vertical flip the image.

axis xy; %set the xy to be at (0,0), this flips the image back again.

哇哇哇,图像现在有一个 y 轴,范围从底部到顶部!

在 MATLAB 中使用 IMAGE 或 IMAGESC 函数显示图像时如何反转 y 轴? mathworks 的另一个解决方案

于 2013-05-17T21:16:19.030 回答
2

我发现 gnovice 的回答很有帮助,但它需要对我进行一些调整。我认为以下是一种更通用的方法来反转 y 轴上的标签。只需按降序对 y 刻度数进行排序并重新标记。

yTicks = get(gca,'YTick');   
yTicks_reverse = sort(yTicks,2,'descend');                                      
set(gca,'YTickLabel',num2str(yTicks_reverse.')); 
于 2013-12-07T22:53:45.197 回答
0

我从一个重复的问题被重定向到这里: 翻转轴刻度

'ale' 想要做的只是将 y 轴方向翻转为自上而下。如果这是唯一需要的东西,我会使用:

axis ij
于 2014-05-20T06:03:10.850 回答