Plot multiple graphs to a single axis handle
15 views (last 30 days)
I need to plot my graphs by specifying the handle to one of the axis that is in my GUI. I am using a loop to plot each new plot on top of the old ones. If I do not specify the handle each of the separate plots show up, except that everything is plotted to the wrong axis:
for i = 1:n
scatter(xdata, ydata, color_n) % all plots visible, plotted in wrong figure
If I specify the handle, the plots go into the correct axis, but only the last plotted graph shows up. I have used 'hold on', so I thought that they are all being plotted, but that by re-specifying the axis handle, the white background of the plot is covering up all of the old data.
for i = 1:n
scatter(axis_handle, xdata, ydata, color_n) % correct axis, only last plot visible
However, if I now create a second figure and change 'axis_handle' to the handle for the axis in this new window, all plots show up in the second figure (as I would expect they should). So for some reason the old plots are only disapearing when I specify the axis handle within my GUI.
The handle for the GUI is just being passed to the function that does the plotting as one of the input parameters.
Evan on 14 Jun 2013
Edited: Evan on 14 Jun 2013
should work. The only thing I can think of without seeing more of your code is that somehow you're holding a different axes than the ones to which you're plotting. That is, prior to the loop, your current axes somehow aren't the ones to which you will be plotting and therefore "hold on" doesn't hold the ones you're wanting.
I've ran into this in the past when working with GUIs that had two or more axes objects, and I've always found "hold(axes_handles,'on')" to be much safer than "hold on" alone.