フィルターのクリア

get children of a figure

152 ビュー (過去 30 日間)
Richard
Richard 2012 年 7 月 21 日
I have a code below that highlights a defined region in a plot:
x = 1:24;
a = 1;
b = 50;
y = a + (b-1).*rand(length(x),1);
plot(x,y);
h = area([18 20],[max(y) max(y)]);
set(h,'FaceColor',[.5,.5,.5]);
set(h,'EdgeColor',[.5,.5,.5]);
h1 = get(h,'children');
set(h1,'FaceAlpha',0.3);
hold on;
plot(x,y);
hold off;
axis([min(x) max(x) min(y) max(y)]);
Although this works as intended, I am unsure about what get(h,'children') does. Could anyone clarify for me what it does and what is the numeric value it returns?

採用された回答

Walter Roberson
Walter Roberson 2012 年 7 月 22 日
The return value of area() is a handle (an arbitrary double precision value with no inherent significance to the value, but which is used by MATLAB to refer to individual graphics objects.)
area() returns the handle to an areaseries object.
In current implementations, areaseries objects have a single child object that is the handle of a patch object, with the patch being in the shape of the area being filled.
The code takes advantage of the fact that patch objects happen to support transparency (when the OpenGL renderer is used), and sets the patch's transparency to 0.3 which is "fairly transparent" (the range being 0 as completely transparent, to 1 being completely opaque.)

その他の回答 (1 件)

Luffy
Luffy 2012 年 7 月 21 日
編集済み: Walter Roberson 2012 年 7 月 22 日
get(h,'Children')
returns handles of children of current object,current object being figure object.
Handles provide the user with a way of identifying the graphics object that you want information about or whose information you want to alter.
Handles can be either integers or floating point numbers that MATLAB automatically generates for an object.

カテゴリ

Help Center および File ExchangeGraphics Object Properties についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by