Ok, so this is starting to get very frustrating.
I have the following code: (scannedResponse, thetaAxis given here).
clear all
load scannedResponse
load thetaAxis
figure(1); clf(1);
pcolor(1:size(scannedResponse,2), thetaAxis, scannedResponse); shading interp;
figure(2); clf(2);
imagesc(1:s.N.Lsnaps, (thetaAxis), scannedResponse);
So I get two images. One made with pcolor, and one made with imagesc. The pcolor image is correct, because the y-axis is correct, and the lines are where they are supposed to be. The imagesc is wrong, because the y-axis is wrong, and the lines are not where they are supposed to be.


As you can see, the lines of the imagesc image do not agree with the lines of the pcolor image. I cannot seem to get the imagesc y-axis to agree with the pcolor y-axis, and thus give me a similar plot. How do I go about doing that?
P.S. I have already tried the full gamut of flipping the y-axis for imagesc, using the set(gca,'Ydir', 'normal') command, etc etc to no avail.
Thanks.
The problem is that thetaAxis contains non-equally spaced values. pcolor can deal with that, imagesc can't. A solution is to interpolate your data to get them on an equally spaced grid:
% determine interpolation grid: from min to max in equal steps
intpoints = linspace(min(thetaAxis), max(thetaAxis), numel(thetaAxis));
% interpolate the data to fit the new "axis"
int = interp1(thetaAxis', scannedResponse, intpoints);
% plot the interpolated data using the new "axis"
imagesc(1:size(scannedResponse,2), intpoints, int)
% revert the direction of the y axis
axis xy
Except for the implicit smoothing that pcolor appears to do, this plot looks identical to the one using pcolor(1:size(scannedResponse,2), thetaAxis, scannedResponse); shading interp.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With