MATLAB: Are the figure’s axis disappeared after I put an image on the plot

axisimageMATLABplot

I've created this function:
function [] = GroundTrack(VettXs, VettYs, VettZs, omegarot, dt, Nt)
alphadate = evalin('base', 'alphadate');
figure('position', [25 200 800 500])
M = imread('Earth texture.jpg');
S = imread('Satellite icon.png');
imagesc([-180 180], [-90 90], M); daspect([1 1 1]); hold on
xlabel('Longitude [deg]');
ylabel('Latitude [deg]'); title('Satellite ground track');
% Supponendo che il satellite venga sempre lanciato dalla longitudine per
% cui passa l'asse X dell'IRF la prima posizione del satellite dipenderà
% dalla data del lancio selezionata dall'utente.
[longitudei,latitudei, altitudei] = cart2sph(VettXs(2),VettYs(2),VettZs(2));
plot((longitudei + alphadate)*180/pi, latitudei*180/pi, 'g.', ...
'markersize', 16); hold on
I = imshow(S, 'XData', [longitudei*180/pi - 3 longitudei*180/pi + 3], ...
'YData', [latitudei*180/pi - 3 latitudei*180/pi + 3]);
for i = 3 : Nt-1
[longitude,latitude, altitude] = cart2sph(VettXs(i),VettYs(i),VettZs(i));
beta = omegarot*dt*i;
a = longitude - beta + alphadate;
n = a/(2*pi);
if (n - floor(n)) <= 0.5
a = 2*pi*(n - floor(n));
else
a = -2*pi*(1 - (n - floor(n)));
end
plot(a*180/pi, latitude*180/pi, 'r.'); hold on
delete(I);
I = imshow(S, 'XData', [a*180/pi - 3 a*180/pi + 3], 'YData',...
[latitude*180/pi - 3 latitude*180/pi + 3]);
drawnow
end
[longitudef,latitudef, altitudef] = cart2sph(VettXs(Nt),VettYs(Nt),VettZs(Nt));
gamma = longitudef - omegarot*dt*Nt + alphadate;
n = gamma/(2*pi);
if (n - floor(n)) <= 0.5
gamma = 2*pi*(n - floor(n));
else
gamma = -2*pi*(1 - (n - floor(n)));
end
plot(gamma*180/pi, latitudef*180/pi, 'y.',...
'markersize', 16);
end
After I put the object "I" (therefore "S" too) in the function, the axis of the figure's plot indicating latitude and longitude disappeared for some reason (only the labels remain but the axis are gone). I've already tried putting imshow before plot in the for cycle but the axis still don't appear. Why does this happen, and how can I bring them back?

Best Answer

When imshow is used in an axes that has hold off and if the axes seems to be in the default position as if it is the only axes, then in that case imshow deletes axes and then proceeds. This is not the case you are encountering as you have hold on.
If imshow is used in an axes not in the default position and hold is off then it does cla. This is not the case you are encountering as you have hold on.
In all cases imshow turns the axes off.
The way to fix the problem is to not use imshow . Use image() or imagesc()