Plot shows wrong y-axis labels

I am trying to plot a graph, but my y-axis labels are wrong. I have created an array for this reason: wavelength = linspace(747.067,802.822,1024); and I want to plot from 760 to 790. It looks that image is correct, but y-axis simply prints out all values from the wavelength array in order. x-axis is working properly although I did it in the same way. I don't know why this is happening. My code:
A = dlmread('c13_1.txt',',');
wavelength = linspace(747.067,802.822,1024);
y = linspace (-15,15,256);
h=pcolor( y, wavelength, transpose(A(:,2:1025)));
set(h,'EdgeColor','none'), set(gca,'Ydir','normal'),set(gca,'FontSize',12)
set(gca,'YTickLabel',wavelength);
ylabel('Energy'), xlabel('k-space');
set(gca,'Ydir','reverse');
axis([-15 15 760 790 ])
Also attaching the plot itself:

2 件のコメント

KSSV
KSSV 2017 年 4 月 5 日
You mean you have used axis([-15 15 760 790 ]), this and y label should be between 760 and 790?
LG9
LG9 2017 年 4 月 5 日
Yes, this is correct.

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

 採用された回答

KSSV
KSSV 2017 年 4 月 5 日

1 投票

Your plot is correct....actually you are confused with the axes....the y-axis you are talking about is wavelength and it is in proper range as given. See the below to avoid confusion:
% wavelength = linspace(747.067,802.822,1024);
x = linspace (-15,15,256);
y = linspace(747.067,802.822,1024);
A = rand(length(x),length(y)) ;
h=pcolor( x,y, transpose(A(:,2:1025)));
set(h,'EdgeColor','none'), set(gca,'Ydir','normal'),set(gca,'FontSize',12)
set(gca,'YTickLabel',y);
ylabel('Energy'), xlabel('k-space');
set(gca,'Ydir','reverse');
axis([-15 15 760 790 ])

1 件のコメント

Silver
Silver 2018 年 11 月 14 日
I had the same issue and it works :D thank you for sharing dude !

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

その他の回答 (0 件)

カテゴリ

質問済み:

LG9
2017 年 4 月 5 日

コメント済み:

2018 年 11 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by