# How to "merge" various graphics 2d into one 3d graphic? [duplicate]

I did some calculations and as result got a 2D graphic, but at the beginning of the work I used a constant parameter. What I want is to make a 3D graphic with this parameter as an axis, varying from 1 to 100. How to proceed?

• Hi ! You have to provide a minimum working example that illustrates the whole problem, so we can start working. Aug 15, 2014 at 0:41
• Can you give some more details on how you generated the 2D graphics?
– user484
Aug 15, 2014 at 0:41

Generally speaking Mathematica has 3D versions of everything, so you are probably best to use those from the start. But if you really want to convert 2D to 3D, then you could do it with a set of rules:

Clear[linerule];
linerule[z_] := Line[points_, stuff___] :> Line[{First@#, Last@#, z} & /@ points, stuff];
Clear[textrule];
textrule[z_] := Text[t_, {x_, y_}, stuff___] :> Text[t, {x, y, z}, stuff];
(* pointRule, graphicsComplexRule, polygonRule, etc. *)
Clear[allrules];
allrules[z_] := {linerule[z], textrule[z]};


It's not so simple as taking a list of two numbers to a list of three. Sometimes your list of two numbers might not be a 2D point. So these rules specifically target the bits which we know are coordinates. Some primitives like Circle are going to be more that just appending a z coordinate.

As an example use:

Clear[p];
p[z_] := Plot[(x - z)^2, {x, 0, 1}, PlotRange -> {{0, 1}, {0, 1}}, PlotStyle -> Thick];

Graphics3D[
Table[First@FullGraphics@p[z] /. allrules[z], {z, 0, 1, 0.2}]
, Boxed -> False] • In routine maintenance I was preparing to delete this old closed question, but your answer seems interesting. Since the question is otherwise abandoned would you consider editing it to specifically fit this answer, or reposting this in a self-Q&A? Jul 25, 2015 at 13:46