Matlab Image and Plot with Unexpected Flip

前端 未结 2 1270
花落未央
花落未央 2021-01-22 12:48

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

2条回答
  •  囚心锁ツ
    2021-01-22 13:50

    This is not exactly a problem of rotation, but more a problem of vertical flip.

    If you look carefully at your first two plots, you'll see that the vertical scales are flipped, so if you combine your two plots directly (whatever the way) you will end up with what you observe, i.e. one plot that is flipped with respect to the other.

    I would suggest to flip the contour plot before superposition:

    hold on
    image([-180 180], [-90 90], worldMap);
    title('Declination at elev = 0 km');
    contour(X, Y, flipud(dec0Mat), contoursAt, 'ShowText','on', 'LineWidth', 2);
    colormap('Gray');
    

    or

    hold on
    image([-180 180], [-90 90], worldMap);
    title('Declination at elev = 0 km');
    contour(X, -Y, dec0Mat, contoursAt, 'ShowText','on', 'LineWidth', 2);
    colormap('Gray');
    

    Best,

提交回复
热议问题