In the examples below, there are some obvious code differences in each case, but I don't understand how they would change the orientation of the image or the plot, as shown in each case.
The original image has a size of 407 x 813 x 3.
For the data in the contour, X ranges from -180 to +175, Y ranges from -85 to +85
For the image, I am trying to fit it so that X ranges from -180 to +180, Y ranges from -90 to +90. So the image covers a slightly wider geographic range than the image does.
I have a contour plot of some geographic data. It plots like this, and looks like I expect it to look:
The code to plot this looks is
figure (1);
contour(X, Y, dec0Mat,contoursAt, 'ShowText','on', 'LineWidth', 2);
colormap('Gray');
I can plot the image by itself, and it looks ok:
using this code: figure (99) imagesc([-180 180], [-90 90], worldMap);
But when I try to combine the two, I get this:
Using this code:
figure (1);
image([-180 180], [-90 90], worldMap);
hold on
title('Declination at elev = 0 km');
contour(X, Y, dec0Mat,contoursAt, 'ShowText','on', 'LineWidth', 2);
colormap('Gray');
In this case the map looks right, but the contour is flipped vertically.
In another case, I get this:
Using this code:
figure (3);
hold on
title('Declination at elev = 30 km');
imagesc([-180 180], [-90 90], worldMap);
contour(X, Y, dec30Mat,contoursAt, 'ShowText','on', 'LineWidth', 2);
colormap('Gray');
In this case the map is flipped vertically and the contour is plotted right.
Going by the Matlab documentation for imagesc, it says:
imagesc(x,y,C) displays C as an image and specifies the bounds of the x- and y-axis with vectors x and y. If x(1) > x(2) or y(1) > y(2), the image is flipped left-right or up-down, respectively. If x and y are scalars, the image is translated to the specified location (x,y) such that the upper left corner of the image starts at (x,y).
I highlighted what might be relevant for an image being flipped, but neither seems to be the case here and wouldn't explain the inconsistency where is is flipped in one case and not the other.