user interface - Unable to show 2 graphs with grid on in Matlab GUI -
i making gui in matlab. sample of code
function plotresults(handles) % create output data plot in proper axes plot(handles.outputaxes, handles.outputcurrentdata, handles.outputvoltagedata,'.-') set(handles.outputaxes, 'xminortick', 'on') grid on % create magnet data plot in proper axes plot(handles.magnetaxes, handles.magnetcurrentdata, handles.magnetvoltagedata, '.-') set(handles.magnetaxes, 'xminortick', 'on') grid on
however, 2nd axis displays grid, first not. can tell me why? thanks
that peculiar behaviour. able reproduce simple gui , no matter how ordered above code (outputaxes
before magnetaxes
) magnetaxes
had grid displayed , other had removed (maybe because added magentaxes
widget second?).
the grid on
statement turns grid on current axis maybe part of confusion - magnetaxis
has "focus" , gets updated grid while other not because never set current axis.
two solutions follows - specify axis wish enable grid
grid(handles.outputaxes,'on'); % replace grid on first axis grid(handles.magnetaxes,'on'); % replace grid on second axis
or remove grid on
statements altogether , do
set(handles.outputaxes, 'xminortick', 'on','xgrid','on','ygrid','on'); set(handles.magnetaxes, 'xminortick', 'on','xgrid','on','ygrid','on');
a third option manually set current axis before calling grid on
(i.e. axes(handles.outputaxes);
).
Comments
Post a Comment