I am trying to update a series of plots within a subplot in a GUI

3 views (last 30 days)
I am programming a GUI to take in data from .dat files and graph them. The options should create a subplot with up to 3 selections being made meaning I can have 1 plot or up to 3 plots being displayed on an axes. Right now I can plot and see the correct plot for only the first iteration with successive plots being displayed in the figure window, or only have the plots being displayed in the figure window. My main point of contention is also the fact that I need to save a copy of the subplots later on.
I've attached my code but am unsure what to do to have consistent plotting within the window that does not plot in the matlab figure window at all.
handles.hfig = figure;
guidata(hObject, handles);
%wind speed
if windSpeedCheckValue == 1
n = n+1;
set(0,'CurrentFigure',handles.hfig);
subplot(3,1,n);
% hold on
[tout, dataout] = average_data(t, H2O, 20*AveragingTime);
plot(tout, dataout, 'LineWidth', LineWidth);
% hold off
datetick('x', 'HH:MM:SS');
xlabel('t');
ylabel('H_2O (mmol/m^3)');
box on
if n == 1
title(date);
end
else
% try
% %This gets rid of plot elements such as lines when specific
% %subpot not used
% children = get(handles.plot1, 'children');
% delete(children(1));
% %Hides the plot when checkbox not selected
% set(handles.plot1,'visible', 'off');
% % if windDirectionCheckValue == 1
% % set(handles.plot3,'visible', 'off');
% % end
%
% % handles.plot1 = rmfield(handles, 'plot1');
% end
end
%vertical wind speed
if vertWindSpeedCheckValue == 1
n = n+1;
set(0,'CurrentFigure',handles.hfig);
subplot(3,1,n);
% hold on
[tout, dataout] = average_data(t, H2Oabs, 20*AveragingTime);
plot(tout, dataout, 'LineWidth', LineWidth);
% hold off
datetick('x', 'HH:MM:SS');
xlabel('t');
ylabel('H_2O Absorbance');
box on
if n == 1
title(date);
end
else
% try
% children = get(handles.plot2, 'children');
% delete(children(1));
% set(handles.plot2,'visible', 'off');
% % handles.plot2 = rmfield(handles, 'plot2');
% end
end
%wind direction
if windDirectionCheckValue == 1
% try
% if windSpeedCheckValue == 0
% set(handles.plot3,'visible', 'on');
% end
% end
n = n+1;
set(0,'CurrentFigure',handles.hfig);
subplot(axes,3,1,n);
% hold on
[tout, dataout] = average_data(t, P7500, 20*60);
plot(tout, dataout, 'LineWidth', LineWidth);
% hold off
datetick('x', 'HH:MM:SS');
xlabel('t');
ylabel('P7500 (kPa)');
box on
if n == 1
title(date);
end
else
% try
% children = get(handles.plot3, 'children');
% delete(children(1));
% set(handles.plot3,'visible', 'off');
% % handles.plot3 = rmfield(handles, 'plot3');
% end
end
%set the axis as the parent of the image within the imshow command
imshow(handles.hfig,'Parent',handles.axes1);
handles.saveFigure = findobj(gcf,'Type', 'figure');
guidata(hObject, handles);

Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!