Clear Filters
Clear Filters

AppDesigner: bar graph behaves differently when using breakpoints

2 views (last 30 days)
Hi all. I'm having an odd issue with MATLAB. I'm using AppDesigner to analyze an Excel Spreadsheet and display the results on screen. The output figure has two axes, one of which is a bar graph, and the other of which is a line graph which is used to summarize certain of the bar graph results:
This is what this graph is supposed to look like. It's what the graph does look like if I set a breakpoint before the line graph is plotted. However, if I run it straight through without any breakpoints (or with a breakpoint after the line is plotted), this is what it looks like:
What appears to happen is that the bar graph suddenly ignores the "grouped" setting and instead displays as if it were three sets of data plotted concurrently. You can get the same output by turning on 'hold' and running three different bar functions. Oddly enough, this behavior occurs if I place the breakpoint directly in front of the relevant "plot" command, before the plot command is even called. This appears to be independent of the code entered directly before the plot command. Update: the previous statement is wrong. This behavior does appear to be linked to the yyaxis command, and not the plot command.
Any ideas about what could be causing this? I'll post the relevant portion of the code, which is rather lengthy.
function PlotButtonPushed(app, event)
app.PCBlist = [];
app.actions = [];
app.daynum = [];
yyaxis(app.UIAxes,'right');
cla(app.UIAxes);
yyaxis(app.UIAxes,'left');
cla(app.UIAxes);
legend(app.UIAxes,'off');
app.regraph;
end
function regraph(app)
% Several try/catch error catching functions.
switch app.DataDivs.Value
case 'Years'
datintv = calyears(1);
formatout = 'mmm yyyy';
case 'Quarters'
datintv = calmonths(3);
formatout = 'dd mmm yy';
case 'Months'
datintv = calmonths(1);
formatout = 'dd mmm yy';
case 'Weeks'
datintv = caldays(7);
formatout = 'dd mmm yy';
case 'Days'
datintv = caldays(1);
formatout = 'dd mmm yy';
case 'Hours'
datintv = hours(1);
formatout = 'mmm dd HH:MM';
case 'Minutes'
datintv = minutes(1);
formatout = 'mmm dd HH:MM';
otherwise
datintv = abs(date_d - app.daynum(1))/10;
formatout = 'mm/dd/yy HH:MM';
end
if date_d < datend
app.daynum = date_d:datintv:datend;
else
app.daynum = datend:datintv:date_d;
end
app.daynum.TimeZone = 'America/Los_Angeles';
yyaxis(app.UIAxes,'left');
app.UIAxes.ColorOrder = lines();
app.UIAxes.NextPlot = 'add';
switch app.Dropgraph.Value
case 'Bar Graph'
app.reactbar(formatout,false);
case 'Line Graph'
app.reactline(formatout);
case 'Stacked Bar'
app.reactbar(formatout,true);
end
app.ResultsTable.Data = num2cell(app.actions);
app.ResultsTable.ColumnName = app.PCBlist;
for idx = 1:length(app.daynum)-1
rowname(idx) = strcat(cellstr(app.daynum(idx)), '–', cellstr(app.daynum(idx+1)));
end
if app.AverageSwitchingActionsCheckBox.Value
app.allswitch;
end
if app.AverageReactorActionsCheckBox.Value
app.allreact;
end
if app.AverageCapActionsCheckBox.Value
app.allcap;
end
app.ResultsTable.RowName = rowname;
end
function reactbar(app,formatout,stacked)
if stacked
stackout = 'stacked';
else
stackout = 'grouped';
end
[~,PCBs] = app.elemlist;
for idx = 2:length(app.daynum)
for jdx = 1:length(app.PCBlist)
app.actions(idx-1,jdx) = sum(isbetween(app.datatable.Time(PCBs(jdx,:)),app.daynum(idx-1),app.daynum(idx)));
end
end
if ~isempty(app.actions)
bar(app.UIAxes,app.actions,stackout);
else
return
end
if stacked
yax = 1.2 * max(sum(app.actions));
else
yax = 1.2 * max(max(app.actions));
end
app.graphformat(formatout, yax);
end
function allswitch(app)
totacts = mean(app.actions,2);
yyaxis(app.UIAxes,'right');
plot(app.UIAxes, totacts);
app.UIAxes.YAxis(end).Limits = app.UIAxes.YAxis(1).Limits;
app.UIAxes.Legend.String(end) = {'Ave. Switch Actions'};
end

Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!