a Line to plot by using handles ?

9 ビュー (過去 30 日間)
Max Müller
Max Müller 2014 年 8 月 18 日
編集済み: John Kelly 2015 年 2 月 12 日
Hey Guys,
Monday Morning Question: I have got an array(1x40) holding new y-Data. Now I want to plot this data in an existing Plot. Of course i could use gca / get(...,'children') / x = get(children,'xdata') to replot, but is there anyway to add the new Data and replot by using the childrens handles ?
  1 件のコメント
Adam
Adam 2014 年 8 月 18 日
編集済み: Adam 2014 年 8 月 18 日
I'm not quite sure I understand which children's handles you mean.
If you keep hold of your axes handles then you don't need to use children and refind them at all, just a
hold( hAxes, 'on' )
plot( hAxes,... )
will do to be able to add new data to an existing plot.
I often have my axes embedded in my main gui so obviously they are easy to retrieve the handles of, but where I spawn a new figure I tend to store its axes (or figure handle, whichever I think more useful) on the handles structure of my GUI for retrieval.

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

採用された回答

Michael Haderlein
Michael Haderlein 2014 年 8 月 18 日
Of course i could use gca / get(...,'children') / x = get(children,'xdata') to replot, but is there anyway to add the new Data and replot by using the childrens handles ?
The get(...,'children') gives you the children's handles. If you haven't saved them when creating the plots, you'll need to get them this way. However, you can set the new y values by set(handle,'ydata',y).
No need to say that the dimensions must remain.
  2 件のコメント
Michael Haderlein
Michael Haderlein 2014 年 8 月 18 日
編集済み: Michael Haderlein 2014 年 8 月 18 日
Sorry, what do you want to do? You want to add plots without using the plot() function? I have no idea what this should be good for, but if you really want to do that, you could copy an existing plot and modify it:
h=copyobj(get(gca,'children'),gca);
set(h,'ydata',rand(size(get(h,'ydata'))))
(in this example, of course, I only had one plot existing before - otherwise that setting would fail as get(h,'ydata') would return a cell)
Max Müller
Max Müller 2014 年 8 月 18 日
My 1st Program Plots my 9 subplots with an unknown amount Plotines. Now I am creating a Program to get all the yValue, calculate the mean and plot the mean as a new line into the old axes of the subplot.

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

その他の回答 (2 件)

Max Müller
Max Müller 2014 年 8 月 18 日
Still dont get it. I want to add a new PlotLine without using the Plot command. So i guess i need to create a new handle in the children structure cause every children is already holding its y-Value.
  5 件のコメント
Max Müller
Max Müller 2014 年 8 月 18 日
編集済み: John Kelly 2015 年 2 月 12 日
no. I cant cause my PlotingProgram is far too complicated.
Max Müller
Max Müller 2014 年 8 月 18 日
I need to replot the whole subplots....is it possible to replot a plot by using the plots handle ?

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


Max Müller
Max Müller 2014 年 8 月 18 日
Got it. Using Plot and hold on works not perfect but....it works

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by