1
$\begingroup$

I have a list x95 (notice how the increment changes from 0.05 to 0.005 towards the end):

{{0}, {0.05`}, {0.1`}, {0.15`}, {0.2`}, {0.25`}, {0.3`}, {0.35`}, 
{0.4`}, {0.45`}, {0.5`}, {0.55`}, {0.6`}, {0.65`}, {0.7`}, {0.75`},
{0.8`}, {0.85`}, {0.9`}, {0.95`}, {1}, {1.05`}, {1.1`}, {1.15`}, 
{1.2`}, {1.25`}, {1.3`}, {1.35`}, {1.4`}, {1.45`}, {1.5`}, {1.55`},
{1.6`}, {1.65`}, {1.7`}, {1.75`}, {1.8`}, {1.85`}, {1.9`}, {1.95`},
{2}, {2.05`}, {2.1`}, {2.15`}, {2.2`}, {2.25`}, {2.3`}, {2.35`}, 
{2.4`}, {2.45`}, {2.5`}, {2.55`}, {2.6`}, {2.65`}, {2.7`}, {2.75`},
{2.8`}, {2.85`}, {2.9`}, {2.95`}, {3}, {3.05`}, {3.1`}, {3.15`}, 
{3.2`}, {3.25`}, {3.3`}, {3.35`}, {3.4`}, {3.45`}, {3.5`}, {3.55`},
{3.6`}, {3.65`}, {3.7`}, {3.70497474`}, {3.70997474`}, {3.71497474`}, 
{3.71997474`}, {3.72497474`}, {3.72997474`}, {3.73497474`}, {3.73997474`},
{3.74497474`}, {3.74997474`}, {3.75497474`}, {3.75997474`}, 
{3.76497474`}, {3.76997474`}, {3.77497474`}, {3.77997474`}, 
{3.78497474`}, {3.78997474`}}

And a list f95 (new paragraph corresponds to the increments switch of x95):

{{-0.011658568`}, {-0.0096303775`}, {-0.0076848125`}, 
{-0.0057832125`}, {-0.00392636`}, {-0.0021098835`}, {-0.000339062`},
{0.0013843615`}, {0.003072948`}, {0.0047233835`}, {0.006339129`}, 
{0.007899272`}, {0.0094290445`}, {0.0109139055`}, {0.0123779205`}, 
{0.0137939155`}, {0.0151725645`}, {0.016522783`}, {0.0178391455`}, 
{0.0191238585`}, {0.0203645985`}, {0.021585122`}, {0.0227680155`}, 
{0.0239206115`}, {0.0250345905`}, {0.0261265775`}, {0.027196839`}, 
{0.028219475`}, {0.0292256795`}, {0.0302053775`}, {0.031153609`}, 
{0.032070067`}, {0.0329778765`}, {0.033838429`}, {0.034681311`}, 
{0.035495814`}, {0.036306521`}, {0.037065547`}, {0.0378140655`}, 
{0.0385447895`}, {0.039250012`}, {0.0399386065`}, {0.040598848`}, 
{0.0412283045`}, {0.0418467445`}, {0.0424523565`}, {0.0430087655`},
{0.0435565075`}, {0.0441070605`}, {0.044619163`}, {0.0451372175`}, 
{0.0456159075`}, {0.046084604`}, {0.046534717`}, {0.046982633`}, 
{0.0474072485`}, {0.0478109985`}, {0.0482038205`}, {0.0485703495`},
{0.0489372695`}, {0.049276349`}, {0.0496135135`}, {0.0499217255`}, 
{0.0502257995`}, {0.0505225905`}, {0.0507854845`}, {0.0510497065`},
{0.0513002635`}, {0.0515403305`}, {0.0517684665`}, {0.0519712595`},
{0.052158684`}, {0.052357398`}, {0.0525214875`}, {0.052670356`},

{0.0526849085`}, {0.05269907`}, {0.052704355`}, {0.0527211285`}, 
{0.052730587`}, {0.052742517`}, {0.052750964`}, {0.0527590795`}, 
{0.0527687525`}, {0.0527770315`}, {0.052783427`}, {0.052786248`},
{0.0527845865`}, {0.0527776325`}, {0.0527652825`}, {0.05274558`},
{0.0527230645`}, {0.006090035`}}

Both lists are 93 elements long. These are the x and y coordinates that I want to put in a ListPlot. I used the command

xy95 = Partition[Flatten[Riffle[x95, f95], 1], 2]

but got this (I made a new paragraph where Riffle "messes up"):

{{0, -0.011658568`}, {0.05`, -0.0096303775`}, {0.1`, -0.0076848125`},
{0.15`, -0.0057832125`}, {0.2`, -0.00392636`}, {0.25`, -0.0021098835`}, 
{0.3`, -0.000339062`}, {0.35`, 0.0013843615`}, {0.4`, 0.003072948`},
{0.45`, 0.0047233835`}, {0.5`, 0.006339129`}, {0.55`, 0.007899272`},
{0.6`, 0.0094290445`}, {0.65`, 0.0109139055`}, {0.7`, 0.0123779205`}, 
{0.75`, 0.0137939155`}, {0.8`, 0.0151725645`}, {0.85`, 0.016522783`},
{0.9`, 0.0178391455`}, {0.95`, 0.0191238585`}, {1, 0.0203645985`},
{1.05`, 0.021585122`}, {1.1`, 0.0227680155`}, {1.15`, 0.0239206115`},
{1.2`, 0.0250345905`}, {1.25`, 0.0261265775`}, {1.3`, 0.027196839`},
{1.35`, 0.028219475`}, {1.4`, 0.0292256795`}, {1.45`, 0.0302053775`}, 
{1.5`, 0.031153609`}, {1.55`, 0.032070067`}, {1.6`, 0.0329778765`}, 
{1.65`, 0.033838429`}, {1.7`, 0.034681311`}, {1.75`, 0.035495814`}, 
{1.8`, 0.036306521`}, {1.85`, 0.037065547`}, {1.9`, 0.0378140655`},
{1.95`, 0.0385447895`}, {2, 0.039250012`}, {2.05`, 0.0399386065`},
{2.1`, 0.040598848`}, {2.15`, 0.0412283045`}, {2.2`, 0.0418467445`},
{2.25`, 0.0424523565`}, {2.3`, 0.0430087655`}, {2.35`, 0.0435565075`}, 
{2.4`, 0.0441070605`}, {2.45`, 0.044619163`}, {2.5`, 0.0451372175`},
{2.55`, 0.0456159075`}, {2.6`, 0.046084604`}, {2.65`, 0.046534717`},
{2.7`, 0.046982633`}, {2.75`, 0.0474072485`}, {2.8`, 0.0478109985`},
{2.85`, 0.0482038205`}, {2.9`, 0.0485703495`}, {2.95`, 0.0489372695`},
{3, 0.049276349`}, {3.05`, 0.0496135135`}, {3.1`, 0.0499217255`},
{3.15`, 0.0502257995`}, {3.2`, 0.0505225905`}, {3.25`, 0.0507854845`}, 
{3.3`, 0.0510497065`}, {3.35`, 0.0513002635`}, {3.4`, 0.0515403305`}, 
{3.45`, 0.0517684665`}, {3.5`, 0.0519712595`}, {3.55`, 0.052158684`}, 
{3.6`, 0.052357398`}, {3.65`, 0.0525214875`}, {3.7`, 0.052670356`},

{3.70497474`, 0.0527773175`}, {3.70997474`, 0.0060403695`}, 
{3.71497474`, -0.011658568`}, {3.71997474`, -0.0096303775`}, 
{3.72497474`, -0.0076848125`}, {3.72997474`, -0.0057832125`}, 
{3.73497474`, -0.00392636`}, {3.73997474`, -0.0021098835`},
{3.74497474`, -0.000339062`}, {3.74997474`, 0.0013843615`},
{3.75497474`, 0.003072948`}, {3.75997474`, 0.0047233835`},
{3.76497474`, 0.006339129`}, {3.76997474`, 0.007899272`}, 
{3.77497474`, 0.0094290445`}, {3.77997474`, 0.0109139055`}, 
{3.78497474`, 0.0123779205`}}

As you can see, it kept riffling the x95 elements correctly up until the x increment changed, and then f95 kind of broke down and it invented random new elements. The "second paragraph" of f95 does not match the y coordinate for the second paragraph of xy95. I have no idea why it stopped working correctly though I realize it probably has something to do with the upset pattern in x95.

$\endgroup$
1
  • 1
    $\begingroup$ Don't you just want: Transpose@(Flatten /@ {x95, f95})? I otherwise cannot reproduce what you saw. $\endgroup$ – MarcoB Jul 31 '17 at 21:57
2
$\begingroup$

I think you merely want a Join:

new = Join[x95, f95, 2];

Short[new]
{{0, -0.0116586}, {0.05, -0.00963038}, <<89>>, {3.78497, 0.0527231}, {3.78997, 
  0.00609004}}
ListLinePlot[new]

enter image description here

$\endgroup$
7
  • $\begingroup$ That is indeed what I expect the plot to look like. For me this input produced the same output that I saw in the original question. You guys don't seem to have trouble so maybe my version of mathematica is the issue or maybe my computer is just screwy $\endgroup$ – Eric Jul 31 '17 at 23:08
  • $\begingroup$ wait I lied, now I get this: {{0, -0.0116586}, {0.05, -0.00963038}, {0.1, -0.00768481}, {0.15, \ -0.00578321}, {0.2, -0.00392636},<<83>>, {3.76997}, {3.77497}, {3.77997}, {3.78497}, {3.78997}} which is even further from correct. $\endgroup$ – Eric Jul 31 '17 at 23:13
  • $\begingroup$ @Eric More likely your input is not correct. Try copying the data out of your Question itself, since that seems to have worked for me. $\endgroup$ – Mr.Wizard Jul 31 '17 at 23:15
  • $\begingroup$ Well the data in the question is copied from the data that I've been using... $\endgroup$ – Eric Jul 31 '17 at 23:22
  • 2
    $\begingroup$ I'm both happy and really annoyed to report that it turned out to be an issue of turn it off and back on again. Thanks for your suggestions $\endgroup$ – Eric Jul 31 '17 at 23:46
0
$\begingroup$
ListLinePlot@Transpose[Flatten /@ {x95, f95}]

or

ListLinePlot@Partition[Flatten@Riffle[x95, f95], 2]

both give the desired result

enter image description here

$\endgroup$

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