I'm a newcomer to Mathematica, and I'm having trouble with the following question.

Say we have a list of complex numbers list1 and a list of real numbers list2 (with the same amount of elements). I want to produce a 3D plot where list1 is plotted in the complex plane (can consider it as the $\mathrm{xy}$-plane) against list2 plotted in the $\mathrm{z}$-axis (with a point in list1 in the $\mathrm{xy}$-plane, associated to the respective point in list2 in the $\mathrm{z}$-axis). How would I be able to do this? I was thinking of using ListPlot3D but I'm not sure on how to apply it.

Thank you for your help.

  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – Michael E2 Aug 9 '15 at 0:09
  • $\begingroup$ Have you tried Re and Im? $\endgroup$ – Michael E2 Aug 9 '15 at 0:09
  • 1
    $\begingroup$ As in extracting Re, Im of list1 and then plotting it with list2 using ListPlot3D? $\endgroup$ – hoyast Aug 9 '15 at 0:15
  • $\begingroup$ @hoyast, sounds like a plan. $\endgroup$ – J. M.'s discontentment Aug 9 '15 at 0:18
  • 2
    $\begingroup$ @hoyast Try to find out why you can apply Re and Im on lists (lookup Listable) and how easily you can re-arrange columns and rows if you think about it as transposing a matrix (or a tensor in general). Try ListPlot3D[Transpose[{Re[list1], Im[list1], list2}]], but don't just use it. Understand it. $\endgroup$ – halirutan Aug 9 '15 at 0:49

I think we need to get an answer on record, so I will present an example that demonstrates the answers given in the comments to the question.

I start by generating some random data

xy = RandomComplex[{0., 10. + 10. I}, 6]
z = RandomReal[10., 6]
{4.25905 + 2.96848 I, 3.91023 + 2.06408 I, 3.47069 + 3.2517 I, 
 4.53741 + 9.73325 I, 5.55963 + 2.58796 I, 2.89169 + 5.50582 I}

{7.17287, 7.54353, 8.60349, 9.96966, 7.39226, 0.383646}

Then, making use of the Listable attribute of Re and Im, the 3D coordinates are given by

 xyz = Transpose[{Re[xy], Im[xy], z}]
{{4.25905, 2.96848, 7.17287}, {3.91023, 2.06408, 7.54353}, 
 {3.47069, 3.2517, 8.60349}, {4.53741, 9.73325, 9.96966}, 
 {5.55963, 2.58796, 7.39226}, {2.89169, 5.50582, 0.383646}}

and can be visualized by

ListPlot3D[xyz, Mesh -> All]



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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