Plot multiple graphs to a single axis handle

21 ビュー (過去 30 日間)
Peter
Peter 2013 年 6 月 14 日
回答済み: M Armengol 2017 年 5 月 18 日
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.

採用された回答

Evan
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 件のコメント
Peter
Peter 2013 年 6 月 14 日
Yes!

サインインしてコメントする。

その他の回答 (1 件)

M Armengol
M Armengol 2017 年 5 月 18 日
THANK YOU!

カテゴリ

Help Center および File ExchangeSpecifying Target for Graphics Output についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by