How to Manage the Order of Graphics Objects and Plots on an Axes Object?

34 ビュー (過去 30 日間)
Rightia Rollmann
Rightia Rollmann 2017 年 3 月 7 日
編集済み: Jan 2017 年 3 月 7 日
How to manage to specify the order of p1,r1, and r2?
For example, how can I put p1 between r1 and r2?
f = figure;
p1 = plot(-2:4, rand(1, 7))
r1 = rectangle('Position', [0 0 2 2], 'FaceColor', 'r');
r2 = rectangle('Position', [1 1 2 2], 'FaceColor', 'g');
axis([-2 4 -2 4])

採用された回答

Jan
Jan 2017 年 3 月 7 日
編集済み: Jan 2017 年 3 月 7 日
Simply by creating the objects in the wanted order:
f = figure;
axes('NextPlot', 'add'); % As: hold on
r1 = rectangle('Position', [0 0 2 2], 'FaceColor', 'r');
p1 = plot(-2:4, rand(1, 7))
r2 = rectangle('Position', [1 1 2 2], 'FaceColor', 'g');
axis([-2 4 -2 4])
Or afterwards using uistack:
uistack(r2, 'bottom');
uistack(p1, 'top');
uistack(r1, 'top');
Alternatively (perhaps required with the OpenGL renderer), you can define a Z-value for the objects and set the 3D view accordingly. Then plot3 is needed, or the line command, and patch objects.

その他の回答 (0 件)

カテゴリ

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