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?

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

1 Answer 1


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:

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

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

  Table[First@FullGraphics@p[z] /. allrules[z], {z, 0, 1, 0.2}]
, Boxed -> False]


  • $\begingroup$ 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? $\endgroup$
    – Mr.Wizard
    Jul 25, 2015 at 13:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.