Reverse imagesc y-axis tick marks to go from positive to negative values

FireSky picture FireSky · Oct 31, 2013 · Viewed 8.7k times · Source

I am using imagesc on my image1 with is a 2023 x 2023 pixel image.

figure(1)
imagesc(-1016:1015, -1016:1015, image1);

I am atempting to create a cartesian coordinate axis on the image, however the y-axis has range goes from negative to positive instead of positive to negative. I have tried a few different ways to fix the problem but nothing is working.

Tried:

imagesc(-1016:1015, 1016:-1015, image1);
imagesc(-1016:1015, 1016:-1:-1015, image1);
imagesc(-1016:1015, 1016:1:-1015, image1);
imagesc(-1016:1015, -(-1016:1015), image1);
set(gca,'YDir','reverse');

How do you reverse the scale on the y-axis using imagesc?

Answer

nispio picture nispio · Oct 31, 2013

By default, the imagesc function sets the YDir property to reverse. Try

set(gca,'YDir','normal');