How to avoid Matlab keeping old labels on my axis when redrawing
2 views (last 30 days)
Hi, I wish to thank you in advance for any help you can provide. I am having a serious headake trying to get a GUI with a couple of plots inside which correctly update as I change some parameters.
The think is the following, my GUI accepts some parameters plus a button and generates two plots and show them in their respective axes. After a while, I managed so that works in the way that I can change some parameters, press the button again and I wanted to update the plots.
The problem is that the new plots write the axis values over the old ones (they might change with the parameters) and that end up being a mess (you can see it in the picture, the Y axis is overwritten too, but only looks like "Bold" because the values are consistently the same, as that axis represents a probability).
function start_Callback(hObject, eventdata, handles)
myhandles = guihandles(bidding);
%Get the Plots Working
set(myhandles.axes1, 'NextPlot', 'new')
set(myhandles.axes2, 'NextPlot', 'new')
%Get the variables declared by the user
[A B C]=plotyy(n,x,n,xx,'bar','plot');
set(C,'linestyle','-','linewidth',1.5, 'Color', 'red');
[D E F]=plotyy(n,ep,n,xx,'bar','line');
set(F,'linestyle','-','linewidth',1.5, 'Color', 'red');
hold on; tar=plot(n,target); hold off;
That is the code related to the graphs inside the callback. Again I appreciate any help you can provide.
Image Analyst on 8 Aug 2014
Please attach a screenshot. It looks like you're calling cla('reset') so that should wipe out all old information and start fresh. However you're only calling it on axes2, not on axes1. Maybe you should also call it on axes1 also. And you have a linkaxes. Why did you call linkaxes()?