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

查看:1300
本文介绍了如何在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' 当前轴'反向'

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天全站免登陆