Filter löschen
Filter löschen

Plot multiple graphs to a single axis handle

12 Ansichten (letzte 30 Tage)
Peter
Peter am 14 Jun. 2013
Beantwortet: M Armengol am 18 Mai 2017
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
end
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
end
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.

Akzeptierte Antwort

Evan
Evan am 14 Jun. 2013
Bearbeitet: Evan am 14 Jun. 2013
Something like
hold(axes_handle,'on')
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.

Weitere Antworten (1)

M Armengol
M Armengol am 18 Mai 2017
THANK YOU!

Kategorien

Mehr zu Specifying Target for Graphics Output finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by