Plot multiple graphs to a single axis handle
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Evan
2013-6-14
编辑:Evan
2013-6-14
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.
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Performance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!