Hello everyone!

I have a specific problem with the plotyy function. I don’t quite understand what is happening but here is what I want and how I coded it, and then I explain what happens:

I have a uipanel and there is an axis with the handle hax. upon a buttonpress that is also on the panel, a calculation takes place and then something is plotted on this axes with plotyy.

The panel/programm is designed in such a way that a callback function is running at all times and multiple calculations should be able to be performed. Before each new calculation, the axis are cleared with the cla function.

```
p = uipanel;
hax = axes(p, "fontsize", 12, "ygrid", "on", "position", [0.53 0.06 0.15 0.25]);
h.start_button = uicontrol(p, "style", "pushbutton",...
"string", "Start",...
"units", "normalized",...
"fontsize", 15,...
"fontweight", "bold",...
"callback", @(h,e)callback_function(h,p,hax),...
"position", [0.71 0.655 0.265 0.06]);
function callback_function (obj, p, hax)
switch(gcbo)
case {h.start_button}
ax_temp_get = getappdata(get(obj, 'Parent'), 'Axes');
if isempty(ax_temp_get) == true
ax_temp = hax;
cla(ax_temp);
else
ax_temp = ax_temp_get;
cla(ax_temp(1));
cla(ax_temp(2));
endif;
hax = ax_temp;
[ax_temp] = calculation_and_plot (hax);
setappdata(get(obj, 'Parent'), 'Axes', ax_temp);
endswitch
endfunction
set(gcf, "color", get(0, "defaultuicontrolbackgroundcolor"))
guidata (gcf, h)
callback_function (gcf, true);
```

And the code of the calculation_and_plot function is a different .m file with

```
function [ax_temp] = calculation_and_plot (hax);
hax = hax(1);
[ax_temp, h1, h2] = plotyy(hax, x_data, [y_data1, y_data2]);
endfunction;
```

My plan with this is simply always when the start button is pressed, I want to clear the axis on the panel so that a new plot can be plottet there. the problem though is that after the first calculation the axis handle has two handles since plotyy gives 2 handles as output. therefore I implemented the setappdata and getappdata trick to grab the second axis handle if handle so that I can clear it. but the problem is, that after the first iteration the plot just does disappear on the panel competely. I am not sure how to circumvent this problem, has anybody an idea?