如何反转由`imagesc()`函数生成的MatLab图形的Y轴方向
How to reverse the direction of Y-Axis of MatLab figure generated by `imagesc()` function
我正在尝试使用 imagesc()
函数在矩阵中显示数据,但它以降序显示行索引(假设原点在左下角)。知道我可能犯了什么错误或如何纠正这个错误吗?
矩阵中只有 0 和 1。
将 current axes
的 Ydir
属性 设置为 normal
默认情况下,imagesc
对 YDir
使用 reverse
set(gca,'YDir','normal');
请参阅 Documentation 了解坐标轴属性
之前:
之后:
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.
还有一个选项需要的代码略少:
axis ij
Reverse the coordinate system so that the y values increase from top to bottom.
在这种情况下(因为它已经被逆转),你可以使用
axis xy
To get back to normal, so that y values increases from bottom to top.
如 axis
的文档中所述。
我正在尝试使用 imagesc()
函数在矩阵中显示数据,但它以降序显示行索引(假设原点在左下角)。知道我可能犯了什么错误或如何纠正这个错误吗?
矩阵中只有 0 和 1。
将 current axes
的 Ydir
属性 设置为 normal
默认情况下,imagesc
对 YDir
reverse
set(gca,'YDir','normal');
请参阅 Documentation 了解坐标轴属性
之前:
之后:
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.
还有一个选项需要的代码略少:
axis ij
Reverse the coordinate system so that the y values increase from top to bottom.
在这种情况下(因为它已经被逆转),你可以使用
axis xy
To get back to normal, so that y values increases from bottom to top.
如 axis
的文档中所述。