0
$\begingroup$

I have a nested list, such as, {{{a1,b,c1}},{{a2,b,c2}},{{a3,b,c31},{a3,b,c32}},{{a4,b,c41},{a4,b,c42}},...{},...}

The features of the list:

  1. Some sublists have a single ordered triple of numbers, some have more than one triple, e.g. {{a3,b,c31},{a3,b,c32}}, and some are null;

  2. The {-2} level is the level of the triples in their list

  3. b is a fixed constant throughout the list, and c_is are complex numbers.

I want to plot a_i versus the real part of c_i. Because some sublists have more than one triple of numbers and thus multiple c_i values, for the corresponding a_i there will be two points in the plot. Thank you!

Here is an example for testing

listTest = {{{0, 0.01, 0.9108613}}, {{0.01, 0.01, 
0.91076 - 0.00054857 I}}, {{0.02, 0.01, 
0.9104 - 0.0010988078 I}}, {{0.03, 0.01, 
0.9099769 - 0.0016523 I}}, {{0.04, 0.01, 
0.909291 - 0.00221086 I}}, {{0.05, 0.01, 
0.45553 - 10.081423 I}, {0.05, 0.01, 
0.9084125 - 0.0027759 I}}, {{0.06, 0.01, 
0.455581 - 8.40335 I}, {0.06, 0.01, 
0.907342 - 0.00334914 I}}, {{0.07, 0.01, 
0.455634 - 7.205064 I}, {0.07, 0.01, 
0.9060847446 - 0.00393201 I}}, {{0.08, 0.01, 
0.455695 - 6.306 I}, {0.08, 0.01, 0.904641 - 0.004526 I}}, {{0.09,
 0.01, 0.455762 - 5.6080917 I}, {0.09, 0.01, 
0.903 - 0.005132 I}}, {}, {}}
$\endgroup$
1
  • $\begingroup$ Why do you include empty lists? Will these be there in your real use case? $\endgroup$ Jan 14 at 19:07
1
$\begingroup$
alist = listTest /. {a_, b_, c_} -> {a, Re[c]}
blist = Flatten[alist, 2] // Partition[#, 2] &
ListLinePlot[blist, Mesh -> All, MeshStyle -> Black , 
 PlotStyle -> Red]

enter image description here

$\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.