Problem when plotting a matrix

1 回表示 (過去 30 日間)
Yixin Shao
Yixin Shao 2019 年 2 月 20 日
コメント済み: Yixin Shao 2019 年 2 月 26 日
When I use the 'imagesc' function to plot the image with scaled colors, the value on the y coordinate always goes from the min to max from top to bottom, which makes the figure very weird..
I want the y axis to start from 0 to 1, as we usually labelled it..
But even if I get the bottom half and inverse the sequence in my 'Y'(so it goes from 0 to 1), but when plotted, it will again always label it from the min to max from top to bottom... is there any ways I can fix it?
f1 = figure;
imagesc(X,Y,abs(log(Z1shift)));
colorbar;
title('Dispersion M_x');
xlabel('k_x', 'FontSize', 30);
ylabel('f/Hz','FontSize', 30);
set(gca, 'FontSize', 20);
saveas(f1, [sname 'Mx'], 'png');
Mx.png

回答 (1 件)

Agnish Dutta
Agnish Dutta 2019 年 2 月 26 日
編集済み: Agnish Dutta 2019 年 2 月 26 日
From what I understand, you want to plot the values of 'abs(log(Z1shift))' matrix in a particular range.
imagesc(x,y,C) specifies the image location. Use x and y to specify the locations of the corners corresponding to C(1,1) and C(m,n). To specify both corners, set x and y as two-element vectors. To specify the first corner and let imagesc determine the other, set x and y as scalar values. The image is stretched and oriented as applicable.
Refer to the following link for more information:
  1 件のコメント
Yixin Shao
Yixin Shao 2019 年 2 月 26 日
I know, but usually, when you plot something, you what the value increase from origin in y-axis, but when you use imagesc, no matter how you set the "Y", the value will always be adjusted to go from small to large from top to bottom(as I showed, from -1 to 1), which is usually not what we want.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by