更改imshow的轴比例 [英] Change the axis scale of imshow
问题描述
我正在用imshow
可视化MATLAB中的矩阵.但是,我希望y和x轴切换位置,使x对应于矩阵的行索引,而y对应于col索引.
I'm visualizing a matrix in MATLAB with imshow
. However, I'd like the y and x axis to switch places, making x correspond to the row-index of the matrix, and y correspond to the col-index.
我还想将轴的增量值更改为0.01,以使第10行的x值为0.1,第100行的值为1,依此类推.
I also want to change the increment value of the axises to 0.01, so that row 10 has x value 0.1, row 100 has 1 and so on.
推荐答案
要交换轴,您将需要更改轴的视图.默认情况下,2D视图的y轴垂直,x轴水平.您可以通过将视图旋转90度来更改此设置.
To swap the axes you will want to change the view of the axes. By default the 2D view has the y axis vertical and x axis horizontal. You can change this by rotating the view 90 degrees.
view(-90,90) % Default is view(0, 90)
要更改增量,您将要更改imshow
返回的image
对象的XData
和YData
.
To change the increment, you will want to alter the XData
and YData
of the image
object returned by imshow
.
him = imshow(img, []);
set(him, 'XData', [0, size(img, 2)/100], 'YData', [0, size(img, 1)/100]);
这篇关于更改imshow的轴比例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!