# How to create a mirror-symmetrical list

My data file can be found here: data

data = Import["mnl.out", "Table"];


l0 = SplitBy[data, Dimensions][[2 ;; ;; 2]]


and then we plot it

L1 = ListPlot[l0, Frame -> True, Axes -> False, PlotStyle -> {Red},
Joined -> True, PlotRange -> {{6., 13}, {-0.9, 2.4}}]


Now I want to create a new list l1 (with the same structure as l0) so as the corresponding plot (in green) to be mirror-symmetrical with respect to the y = 0 axis.

Any suggestions?

• Related: (38138) Commented Sep 27, 2015 at 9:27

I feel like I must be missing something but this seems to answer your question:

new = Map[{1, -1} # &, l0, {-2}];

ListLinePlot[new, Frame -> True, Axes -> False, PlotStyle -> Green,
PlotRange -> {{6., 13}, {-2.4, 0.9}}]


Since it seems that this is indeed what you want here is a faster but to me more opaque method using Dot:

new2 = l0.{{1, 0}, {0, -1}};

new == new2   (* True *)

• It works like a charm! I tried l1 = Table[{l0[[i, j]][[1]], -l0[[i, j]][[2]]}, {i, 1, Length[l0]}, {j, 1, Length[l0]}] but the new list has less points. Any idea why? Commented Sep 27, 2015 at 9:05
• @Vaggelis_Z You would need to change the second iterator to {j, 1, Length @ First @ l0}. Commented Sep 27, 2015 at 9:23
• "more opaque" - unless you go with the "matrix multiplication" viewpoint. Then, a diagonal matrix is easily interpreted as a scaling transform. Here's the equivalent, but maybe cognitively less demanding version: ScalingTransform[{1, -1}] /@ l0. Commented Oct 8, 2015 at 12:42
• @J.M. Good to have you back! :-) I am not surprised the dot operation is transparent to you but I have yet to reach that level of familiarity with matrix operations. Commented Oct 8, 2015 at 17:48

Just for trivial variety illustrating MapAt and using dummy data (as well as my original version which is not meaningfully different from Mr Wizard: whose answer I have upvoted):

dat = MapIndexed[{#2[[1]], #1} &, #] & /@ RandomReal[1, {3, 10}];
f = {1, -1} # &
ListPlot[Map[f, dat, {2}]~Join~dat, Joined -> True,
PlotStyle -> {Red, Green, Blue}]


now using MapAt:

ListPlot[MapAt[-# &, dat, {All, All, 2}]~Join~dat, Joined -> True,
PlotStyle -> {Red, Green, Blue}]


reflectF = GeometricTransformation[#, ReflectionTransform[{0, -1}]] &;

Show[L1, L1 /. l_Line :> {Green, reflectF @ l}, PlotRange -> {{6., 13}, All}]


l1 = ReflectionTransform[{0, -1}] /@ l0;
ListPlot[l1, PlotStyle -> {Green}, Joined -> True, PlotRange -> {{6., 13}, {-2.4, 0.9}}]