How to set the default corner for origo in imagesc?

I would like to use origo in the bottom-left corner as mathematicians used to.

2 Comments

The answer is: set(gca,'YDir','normal');
Thank you for posting the answer!

Sign in to comment.

Answers (2)

Merse - do you just want to reverse the order of the y-axis so that zero (along y) is in the bottom left corner? Or do you want to be able to manipulate the data in the image given that new ordering? If just the former, then you could do
% get the handle to the image
hImg = imagesc(...);
% get the handle to the parent axes
hAxs = get(hImg,'Parent');
% reverse the order of the y-axis tick labels
yAxisTickLabels = get(hAxs, 'YTickLabel');
set(hAxs,'YTickLabel',flipud(yAxisTickLabels));
The above code just flips the y-axis tick labels so that their order is reversed. NOTE that this does not change the manner in which you can access the data in the image, all it does is flip the labels.

2 Comments

I would like to flip the picture also.
See flipud which will allow you to flip your image.

Sign in to comment.

By default, images use
axis ij
which puts the (1,1) location at the upper left as is the convention for arrays and images. If you want it at the lower left, like an (x,y) plot use
axis xy;

3 Comments

where should I put this modifcation?
After you call plot(), image(), imshow(), or imagesc().
thank you, you are a boss

Sign in to comment.

Asked:

on 14 Nov 2014

Commented:

on 24 Jan 2024

Community Treasure Hunt

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

Start Hunting!