MATLAB: Does `imshow` just delete all other objects in the axes

imageimshow

It seems that imshow just deletes all other objects or handles in the parenting axes. Say I have a script like this
fig = figure;
ax = axes(fig);
text(ax, 0.5, 0.5, 'string');
h0 = findobj(ax, 'Type', 'text');
img = randn(128, 128);
imshow(img); % why is `imshow(ax, img)` illegal?
h = findobj(ax, 'Type', 'text');
h0 is a 1×1 text, but h is empty!
Another wierd behaviour of imshow is that you cannot set the axes in the imshow command, i.e. imshow(ax, img) is not allowed.
Why is imshow so different?

Best Answer

Hello,
To use hold on with handles to axes, this works.
hold(ax, 'on');
To assign image to axes with imshow
imshow(img, 'Parent', ax)