MATLAB: When plotting latitude, how to make indices appear as actual values? using function pcolor

axiscolorplotpcolor

When I just use all latitudes in the file (values -90 to 90) then I do not have problems , but I tried to limit my latitudes to degrees 0 to 90 using this NH=find(latitude<=90&latitude>=0);
and on the plot, the latitudes come up as the indices (~30 to ~75)
this is the code that I used
figure
pcolor(NH,level,T_std_DJF_')
colorbar;
shading flat;
xlabel('Latitude');
ylabel('Level (millibars)');
set(gca,'ylim',[10 1000],'ytick',[10 100:100:1000]);
title('Standard Deviation of Air Temperature DJF 1948-2012');
set(gca,'ydir','reverse')
caxis([1 10])
When I try to edit x limits with set(gca, 'xlim',[0 90], 'XTickLabel', [ 0:10:90 ] ); then it includes big white blank spaces on the sides of the plot. T_std_DJF_ uses the latitudes NH

Best Answer

I'm going to assume that NH is a n x 1 vector of latitude values, level is a m x 1 vector of pressure levels, and T_std_DJF_ is a m x n array of temperature values.
In that case, what you want is
isin = NH <= 90 & NH >= 0;
pcolor(NH(isin), level, T_std_DJF_(:,isin)');
In your code above, you were replacing the actual latitude values (ranging -90-90) with the indices of (not the values of) those elements in your range. I think it's due to remarkable coincidence that the resulting NH array was the correct size for pcolor (not really sure how that's possible...). So your x-values ranged from 30-75 but your axis limits ranged from 0-90, hence the blank space.
You could reset your axis limits to only show 0-90 without trimming the plotted dataset, too.