Reputation: 223
I am trying to display data in a matrix using imagesc()
function but it is showing row index in decreasing order (Assuming origin at left-bottom). Any idea what mistake i could be making or how to correct this?
The matrix only has zeros and ones in it.
Upvotes: 2
Views: 3903
Reputation: 24169
There's another option which requires slightly less code:
axis ij
Reverse the coordinate system so that the y values increase from top to bottom.
As in this case (as it is already reversed), you could use
axis xy
To get back to normal, so that y values increases from bottom to top.
As mentioned in the docs of axis
.
Upvotes: 1
Reputation: 3898
Set Ydir
property of the current axes
to normal
By default, imagesc
uses reverse
for YDir
set(gca,'YDir','normal');
See Documentation for Axes properties
Before:
After:
Note: This completely flips the inside data as well (it supposed to). As you are dealing with matrices, I hope this is what you want.
If you don't want to affect inside data, you need to change order of
YTickLabels
instead.
Upvotes: 3