I have generated a plot using a long list of plot coordinates (x,y). I would like to plot the data as (y,x) with y on the horizontal axis and x on the vertical axis. Is there any way to do that?
I want to avoid generating the data again or invert by hand the (x,y) to (y,x). Thanks!
\begin{tikzpicture}
\begin{axis}[
width=2in,
height=2in,
scale only axis,
xmin=-0.2, xmax=0.15,
xtick={-0.2,-0.1,0,0.1},
scaled x ticks = false,
x tick label style={/pgf/number format/fixed},
ymin=-0.1, ymax=0.7,
scaled y ticks = false,
y tick label style={/pgf/number format/fixed},
axis lines=left,
axis on top]
\addplot[only marks,mark=*,color=blue,line width=2.0pt] plot coordinates{ (-0.157508722022685,-0.0618570189718741) (-0.151664833094664,-0.0515966883381529) (-0.145564835252092,-0.040823938776308) (-0.139190452250407,-0.0294967207779095) (-0.132521672953995,-0.0175681338079243) (-0.12553655513375,-0.00498567308655944) (-0.118211006929595,0.00830966963892551) (-0.110518545011038,0.0223845008246773) (-0.102430029660386,0.0373143588089115) (-0.0939133791975919,0.0531853589452309) (-0.0849332700533765,0.0700962421608876) (-0.0754508355568791,0.0881609593871301) (-0.0654235205799195,0.107511971554234) (-0.0548043511797005,0.128304532815312) (-0.0435426432953672,0.150722344204677) (-0.0315837272782253,0.174985172251473) (-0.0188698246180387,0.201359353223726) (-0.00534192152608734,0.230172683799602) (0.00905671632198194,0.261836217436385) (0.0243733112413743,0.296877414534431) (0.0406316912795995,0.335992918393738) (0.0578048302999246,0.380137343750061) (0.0757586843741441,0.430683077324108) (0.0941307367012631,0.489733069616693) (0.112044793360859,0.560802333252538) (0.127355632830606,0.65053016141635) };
\end{axis}
\end{tikzpicture}
Best Answer
As Jake mentions these type of manipulations are way easier with tables. Here is a quick hack to ignore
(
,)
chars and make the column separator as comma such that we can use coords as inline table entries. (I also swapped x and y settings)