フィルターのクリア

Ordering graphics objects

2 ビュー (過去 30 日間)
Abed Alnaif
Abed Alnaif 2011 年 9 月 26 日
Hi, I have a rectangular and a line graph, and I want to order the rectangle such that it is at the back of the figure (i.e. behind the line graph). How do I do this? I tried to use the set(gca,'Children',...) command, but it didn't work (i.e. the rectangle shows up on top of the graph, and hides the data). My operating system is Mac OS X, in case that matters. See the example code below:
function test_plot( )
figure;
p = plot(ones(5,1));
r = rectangle('Position',[0,0.9,1,0.2],'FaceColor','y');
set(gca,'Children',[p r])
end

採用された回答

Grzegorz Knor
Grzegorz Knor 2011 年 9 月 26 日
Command plot(x) is equivalent to plot(1:numel(x),x). In your example the rectangle is placed before the line on the x axis.
Plot line in this way:
p = plot(0:4,ones(5,1));
r = rectangle('Position',[0,0.9,1,0.2],'FaceColor','y');
set(gca,'Children',[p;r])
  1 件のコメント
Abed Alnaif
Abed Alnaif 2011 年 10 月 6 日
Sorry for the late response, but thanks -- this worked for me!

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

その他の回答 (1 件)

Teja Muppirala
Teja Muppirala 2011 年 9 月 26 日
The UISTACK command is used to order graphics objects.
help UISTACK

カテゴリ

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