how to get current lineseries handle

44 Ansichten (letzte 30 Tage)
Micke Malmström
Micke Malmström am 14 Jun. 2011
if i plot something with h=plot(...) I get a handle to the lineseries, but if I get a plot from somewhere else where I cant get the handle directly is there a way like gcf or gca to get the lineseries handle?

Akzeptierte Antwort

Patrick Kalita
Patrick Kalita am 14 Jun. 2011
The lineseries will (generally) be a child of the axes. So if you have a have a handle to the axes (or using gca, if it is the current axes), you can query its Children property:
>> a = axes;
>> h1 = plot(1:10);
>> h2 = get(a, 'Children');
>> h1 == h2
ans =
1
If you have a very complicated scene (perhaps there are multiple axes involved or maybe hggroups and hgtransforms), it may be easier to use the findobj command:
>> h1 = plot(1:10);
>> h2 = findobj('Type', 'line');
>> h1 == h2
ans =
1

Weitere Antworten (0)

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