set(gca,'XLim',[0 1],'YLim',[0 1], 'SortMethod', 'childorder', 'Visible','on'); instead of set(gca,'XLim',[0 1],'YLim',[0 1], 'Drawmode', 'fast', 'Visible','on');