Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question

closed as unclear what you're asking by RunnyKine, Jens, m_goldberg, Öskå, ubpdqn Aug 15 '14 at 9:45

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

Hi ! You have to provide a minimum working example that illustrates the whole problem, so we can start working. –  Sektor Aug 15 '14 at 0:41
Can you give some more details on how you generated the 2D graphics? –  Rahul Aug 15 '14 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]


share|improve this answer

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