gauss2d0[x_, y_, s11_, s12_, s22_] :=
-Log[
1/Sqrt[(2Pi)^2*(s11*s22-s12^2)]*Exp[-(s22*x^2-2*s12*x*y+s11*y^2)/(2*(s11*s22-s12^2))]
]

twistedgauss2d0[x_, y_, s11_, s12_, s22_, twist_]:=gauss2d0[x*Cos[twist*Norm[{x,y}]]-y*Sin[twist*Norm[{x,y}]],y*Cos[twist*Norm[{x,y}]]+x*Sin[twist*Norm[{x,y}]], s11, s12, s22]

s11 = 1.;
s12 = 1.2;
s22 = 2.;
twist = 0.5;

c1 = Blue;
c2 = Purple;
c3 = Darker[Cyan,0.4];

SetDirectory[StringJoin[NotebookDirectory[], "images/minimization_paths/twisted"]];
images = FileNames["*"];
DeleteFile[images];

SetDirectory[StringJoin[NotebookDirectory[] ,"data/twisted"]];
files=FileNames["*"];

For[p=1, p≤(Length[files]/3), p++,
SetDirectory[StringJoin[NotebookDirectory[] ,"data/twisted"]];
data1 = Import[files[[3p-2]],"Table"];
data2 = Import[files[[3p-1]],"Table"];
data3 = Import[files[[3p]],"Table"];

ct =ContourPlot[.8-.2Log[Log[twistedgauss2d0[x,y,s11, s12, s22, twist]]],{x, -3,3}, {y, -3, 3}, MaxRecursion->3,Contours->10, ColorFunctionScaling->False,LabelStyle->{20,GrayLevel[0.5]}, FrameTicks->{{{-3,-2,-1,0,1,2,3},None},{{-3,-2,-1,0,1,2,3},None}}];

ll1 = ListLinePlot[data1,PlotRange->{{-3,3},{-3,3}}, PlotStyle->Directive[c1]];ll2 = ListLinePlot[data2,PlotRange->{{-3,3},{-3,3}}, PlotStyle->Directive[c2]];
ll3 = ListLinePlot[data3,PlotRange->{{-3,3},{-3,3}}, PlotStyle->Directive[c3]];

lp1 = ListPlot[data1,PlotRange->{{-3,3},{-3,3}}, PlotMarkers->{"■",Medium}, PlotStyle->Directive[c1]];lp2 = ListPlot[data2,PlotRange->{{-3,3},{-3,3}}, PlotMarkers->{"▲",Medium}, PlotStyle->Directive[c2]];lp3 = ListPlot[data3,PlotRange->{{-3,3},{-3,3}}, PlotMarkers->{"●",Medium}, PlotStyle->Directive[c3],TicksStyle->4];

string = StringJoin[files[[3p-2]], "\n", files[[3p-1]], "\n",files[[3p]]];
graphic = Show[ct,ll1,ll2,ll3,lp1,lp2,lp3];
SetDirectory[StringJoin[NotebookDirectory[] ,"images/" ,"minimization_paths/twisted"]];Export[StringJoin[files[[3p-2]],"_",ToString[twist],".gif"],graphic];
Print[GraphicsGrid[{{string,graphic}},ImageSize->Large]];
]