# Flip axes in ListPlot easy way [closed]

I have a list of data. I ploted with ListPlot but I to want flip the axes with a easy way. Instead to Plot (y,U) I want to plot (U,y). There is some option in ListPlot?

Thanks.

• ListPlot[Reverse[points, 2]] or something like it should be useful. Commented Aug 30, 2017 at 17:10
• Thanks! Solved. Commented Aug 30, 2017 at 17:13

From the comments, an easy and efficient way to flip the axes in ListPlot, ListLinePlot and other 2D list plotting functions is to exchange the positions of the abscissa and the ordinate in the list of points:

points = Table[{n, n^Sin[n]}, {n, 1, 10, 0.25}];

{ListPlot[points, ImageSize -> Medium], ListPlot[Reverse[points, 2], ImageSize -> Medium]}


what is equivalent to

ListPlot[Reverse /@ points]]


Another method is to use Part:

ListPlot[points[[All, {2, 1}]]]


It is interesting that RotateRight (or RotateLeft) is more efficient than Reverse but the fastest one is Part:

points = Table[{n, n^Sin[n]}, {n, 1, 10, 0.0000025}];

Reverse[points, 2]; // Timing
Reverse /@ points; // Timing
RotateRight[points, {0, 1}]; // Timing
points[[All, {2, 1}]]; // Timing

{0.405603, Null}

{0.546004, Null}

{0.171601, Null}

{0.109201, Null}

points[[All, {2, 1}]] == RotateRight[points, {0, 1}] == Reverse[points, 2]

True