MATLAB: How to add several graphics to a single GUI.

axesgridguihandlesholdlabel;legendplot

Hi,
I've built a GUI that contains 3 axes (1,2 and 3). I'm unable to add several plots to all the axes without reseting the previous. So, what I want it to enable grid, box, legends and labels to all. With my actual code, it only shows labels on both first and third axes, grid only on the third, and only one plot on the second one. (Screeshot below).
The code I'm using is:
plot (handles.axes1,objetivo(1:itmax));
ylabel(handles.axes1,'Cost (€ / h)')
xlabel(handles.axes1,'Iterations')
plot (handles.axes2,g11(1:itmax));
hold on
plot (handles.axes2,g12(1:itmax));
plot (handles.axes2,g41(1:itmax));
plot (handles.axes2,g42(1:itmax));
legend('PG11','PG12','PG41','PG42','Location','southwest');
ylabel('Power (MW)')
xlabel('Iterations')
hold off
plot (handles.axes3,linha12(1:itmax));
hold on
plot (handles.axes3,linha15(1:itmax));
plot (handles.axes3,linha23(1:itmax));
plot (handles.axes3,linha25(1:itmax));
plot (handles.axes3,linha34(1:itmax));
plot (handles.axes3,linha45(1:itmax));
legend('1-2','1-5','2-3','2-5','3-4','4-5','Location','southwest');
ylabel('Flow (MVA)')
xlabel('Iterations')
hold off
grid on

Best Answer

All those functions take an explicit axes handle as an argument, e.g.
hold( handles.axes2, 'on' )
label( handles.axes2,... )
Don't rely on the current axes when doing a series of instructions on multiple axes - always use the explicit axes handle.