# Inserting element into predefined Show object

I have a predefined function that consists of a number plots combined with Show. Is it possible to add another graphics object at a particular position from the function directly? Simplified example:

figure[x0_] := Show[{
Plot[x - x0, {x, -10, 10}],
Plot[x^2, {x, -10, 10}],
Plot[x^3, {x, -10, 10}]
}];
figure[2]


I want to be able to generate something analogous to:

block = Graphics[{LightRed, Rectangle[{-20, -20}, {0, 0}]}];
Show[{
Plot[x - 2, {x, -10, 10}],
Plot[x^2, {x, -10, 10}],
block,
Plot[x^3, {x, -10, 10}]
}]


with figure(2] and block directly, something functionally similar to

Insert[output[2],block,3]


The key point being that the order matters. Is there a convenient way of doing so?

• Insert[figure[2], block[[1]], {1, 3}]?
– kglr
Apr 10 '19 at 1:27
• It seems that the most straightforward thing is to combine them using the Show statement as follows: Show[{ figure[2], block }]. Apr 10 '19 at 8:07
• @AlexeiBoulbitch The OP wants to insert block between the 2nd part and the 3rd part of figure[2] and precises that the "order matters", hence my answer. Apr 10 '19 at 8:43
• @ andre314 Exactly that I do not understand, since the result is the same. Apr 10 '19 at 9:32
• @AlexeiBoulbitch In this case yes. But it is possible that the OP has over-simplified his example. Apr 10 '19 at 9:47

Insert[figure[2], block[[1]], {1, 3}]


You can do :

figure[x0_] :=
Show[{Plot[x - x0, {x, -10, 10}], Plot[x^2, {x, -10, 10}],
Plot[x^3, {x, -10, 10}]}];

block = Graphics[{LightRed, Rectangle[{-20, -20}, {0, 0}]}];

Show[
Graphics[figure[2][[1, 1]]]
, Graphics[figure[2][[1, 2]]]
, block
, Graphics[figure[2][[1, 3]]]
, Options[figure[2]]]


Options[figure[2]] retrieves the original options of figure[2] that are lost when extracting Graphics[figure[2][[1, 1]]].

EDIT

Note that Show[{ figure[2], block }]doesn't give the result expected by the OP :

> Show[{ figure[2], block }]