1
$\begingroup$

I have a set of data and I would like to plot it. Data looks like this {{1,z1}, {2,z2},..., {n,zn}}. However, the values of z1,.., zn can be complex also. Is there a way to give all the complex values same color but different from real values.
To be precise, I will have 2D plot, where y values are given by z1,.., zn and x values are just natural numbers from 1 to n.
Is there a way to plot this on 2D eventhough z1,.., zn can be complex. Like complex values with one kind of color and real with one kind of color.

I am sorry if this has already been asked.

$\endgroup$
  • $\begingroup$ This seems like a a duplicate, but most of the other deal with {z1, z2 , z3 ... } instead of {{x1, z1}, {x2, z2} , {x3, z3} ... } $\endgroup$ – rhermans Jun 5 '18 at 18:42
1
$\begingroup$

Example data

data = N@Table[{k, Complex[Sin[2 π k/100], Cos[2 π k/100]]}, {k, 100}];

Now you can separate the Real and Imaginary

ListPlot[
 {
  MapAt[Re, data, {All, 2}]
  , MapAt[Im, data, {All, 2}]
  }
 ]

or

ListPlot[
 MapAt[#, data, {All, 2}] & /@ {Re, Im}
 ]

Mathematica graphics

$\endgroup$

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.