Plot multiple graphs to a single axis handle
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Peter
el 14 de Jun. de 2013
Respondida: M Armengol
el 18 de Mayo de 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.
0 comentarios
Respuesta aceptada
Evan
el 14 de Jun. de 2013
Editada: Evan
el 14 de Jun. de 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.
Más respuestas (1)
Ver también
Categorías
Más información sobre Graphics Performance en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!