如何在 MATLAB 中编辑图像的轴以反转方向? [英] How do I edit the axes of an image in MATLAB to reverse the direction?

查看:38
本文介绍了如何在 MATLAB 中编辑图像的轴以反转方向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I would like to edit the axes in my series of images being displayed.

这就是我的形象:

如您所见,它的范围从上到下从 0 到大约 500.我可以颠倒吗?另外,我想镜像显示的图像,使其从左到右开始......或者,如果可能,让轴从右到左显示.

As you can see, it ranges from 0 to about 500 from top to bottom. Can I invert that? Plus, I want to mirror the image being shown, so that it starts from left to right... or, if it's possible, to let the axes show from right to left.

推荐答案

要反转轴,可以设置 'XDir''YDir' 属性 当前轴'reverse':

To reverse an axis, you can set the 'XDir' or 'YDir' property of the current axes to 'reverse':

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

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

Keep in mind that flipping an axis in this way flips everything in the plot as well. This probably isn't what you want to do for the y axis. You probably just want to flip the y axis labels, which you can do by modifying the 'YTickLabel' property in the following way:

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

这篇关于如何在 MATLAB 中编辑图像的轴以反转方向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆