subplot() checks the location information you provide, and figures out what part of the figure that implies. It then checks to see if there is any existing axes that intersects the calculated figure position, and if there is then it deletes the axes unless the axes is exactly the same position as what it just calculated.
Because of the this, subplot can delete existing plots under a couple of circumstances:
- you specified a subplot that spans multiple sections and part was already occupied. You can identify these calls because the third location parameter is a vector, such as subplot(3,2,[3 6])
- you specified a subplot that does not span multiple locations, but it intersects an earlier subplot that did span
- you used subplot when you have an existing plot that did not use subplot
- you used subplot to create a different subplot earlier and adjusted the Position property to make it a different size or position, and now you subplot specifying a location that intersects the expanded location
- you used subplot earlier to define a the location of this axes, and then you set the Position property to customize the location, and now you call subplot to try to return to that logical tile. subplot will notice that the axes is not where it expects and will delete it.
subplot is not a logical layout to say "I want an array of plots that I am going to customize whenever I feel like it." subplot() effectively manages particular sections of the figure, and has no way of marking an axes as "originally" being from a particular subplot. An existing axes it overlays is either exactly in the default position and is used, or else the existing axes is deleted.