Plot 2 graph in GUI in a axes

1 view (last 30 days)
le nguyen
le nguyen on 1 Jun 2019
Commented: dpb on 1 Jun 2019
Hi everyone,
I'm creating a Matlab guide and trying to creat an axes and 2 push button. First, I want to press pushbutton9, a graph will appear, then I press the pushbutton10, i want the second graph will also appear on the axes when the first is still here to compare 2 graph. I'm using the 'hold on' function but whenever I press the pushbutton 10, the first graph disappears. Can anyone help me so this problem?
Thank you so much.
% --- Executes on button press in pushbutton9.
function pushbutton9_Callback(hObject, eventdata, handles)
dataset = xlsread('data.xlsx','Sheet1','A1:B450');
oil = dataset(:,1)
day = dataset(:,2)
plot(handles.axes1,day,oil)
hold on
% --- Executes on button press in pushbutton10.
function pushbutton10_Callback(hObject, eventdata, handles)
data = xlsread('data.xlsx','Sheet1','A2:H450');
day = data(:,2);
oil = data(:,8);
plot(handles.axes1,day, oil,'r')
  1 Comment
dpb
dpb on 1 Jun 2019
Try
  1. hold(handles.axes1,'on') in PB10 code...
  2. Use low-level |line() instead of plot in PB10...

Sign in to comment.

Answers (0)

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!