In order to plot the death cases on either both or right Y-axis I used following functions:
yyaxis(app.UIAxes,'left')
yyaxis(app.UIAxes,'right')
The problem now is, how to undo the settings when switching the radio buttons. These functions seem to freeze the display and the deaths curve won't fade away when I switch to show only covid cases, for instance. My default setting for both will not be replaced when I switch to only cases or only deaths (left radio button below):
This is the code I wrote to select the difference cases(plot function):
function plotData(app) %default values missing
%plot data depending on selection from radion buttons
cla reset if app.ShowCases yyaxis(app.UIAxes,'left') app.UIAxes.YLabel.String='Cases'; plot(app.UIAxes,app.TimeLine,app.Positives); end if app.ShowDeaths yyaxis(app.UIAxes,'right') app.UIAxes.YLabel.String='Deaths'; plot(app.UIAxes,app.TimeLine,app.Deaths); end if app.ShowBoth yyaxis(app.UIAxes,'left') app.UIAxes.YLabel.String='Cases'; plot(app.UIAxes,app.TimeLine,app.Positives); yyaxis(app.UIAxes,'right') app.UIAxes.YLabel.String='Deaths'; plot(app.UIAxes,app.TimeLine,app.Deaths); end end end
And the code I wrote for the event triggering selection from the radio button:
app.ShowCases = app.CasesButton.Value; app.ShowDeaths = app.DeathsButton.Value; app.ShowBoth = app.BothButton.Value; app.plotData;
Without the functions yyaxis(app.UIAxes,'left'/'right') the switch of the plot wil work, but I cannot use the right Y axis though. I have problems to understand the information in the MATLAB documentation and it is not intuitive to found valuable hints by introducing some key words. Thanks in advance to anyone who has a hint for this.
Best Answer