# Flipping the axes of a plot that is produced by a solution of NDSolve [duplicate]

I wish to rotate a plot in the simplest way possible.

I've tried these previously asked questions, but they did not help to produce a good result:

Unlike another post, which the data is a list, here the data is an interpolating function, and I'm not able to reverse the axes:

Here is my sample code and output:

s = NDSolve[{x'[t] == -x[t] + 2 y[t], y'[t] == -4 y[t] x[t],
x == 1, y == 1}, {x, y}, {t, 0, 100}]

Plot[{Evaluate[x[t]] /. s, Evaluate[y[t]] /. s}, {t, 0, 100},
PlotLegends -> Placed[{"x(t)", "y(t)"}, {{0.75, 0.75}, Center}]] What I want to produce is something like I'm looking for a simple implementation, in which I could perform all the plot options (filling, framing etc.).

• @corey979, I've added this post to the body of the question, I cannot implement that procedure on an interpolating function that is produced by NDSolve. – jarhead Apr 16 '18 at 8:44

## 3 Answers

s = NDSolve[{x'[t] == -x[t] + 2 y[t], y'[t] == -4 y[t] x[t],
x == 1, y == 1}, {x, y}, {t, 0, 100}];
plot = Plot[{Evaluate[x[t]] /. s, Evaluate[y[t]] /. s}, {t, 0, 100},
PlotLegends -> Placed[{"x(t)", "y(t)"}, Scaled[{0.75, 0.5}]]]


From Mr. Wizard's answer:

axisRotate = # /. {x_Point | x_Line | x_GraphicsComplex :>
MapAt[(#.{{0, -1}, {1, 0}}) &, x, 1]} &;


with inverted signs of the ticks:

Show[axisRotate@plot, AspectRatio -> GoldenRatio/1, PlotRange -> All,
Ticks -> {Automatic, Table[{-i, i}, {i, 20, 100, 20}]}] This seems to be a pretty simple way. I had to include the option AxesOrigin->{0,0}; otherwise the vertical axes did not turn up.

s=NDSolve[{x'[t]==-x[t]+2 y[t],y'[t]==-4 y[t] x[t],x==1,y==1},{x,y},{t,0,100}];

pic=Plot[{Evaluate[x[t]]/.s,Evaluate[y[t]]/.s},{t,0,100},PlotLegends->Placed[{"x(t)","y(t)"},{{0.75,0.75},Center}], AxesOrigin->{0,0}] pic /.{ Line[pts_]:>Line[Reverse/@ pts], HoldPattern[PlotRange->pr_]:>(PlotRange->Reverse@pr)} pic= Plot[{Evaluate[x[t]] /. s, Evaluate[y[t]] /. s}, {t, 0, 100},PlotLegends -> Placed[{"x(t)", "y(t)"}, {{0.75, 0.75}, Center}]]
MapAt[Rotate[#, -Pi/2] &, pic, {1}] • Thanks for answering, but here the plot is not reversed/transposed – jarhead Apr 16 '18 at 8:42
• Sorry, now I got your question – Ulrich Neumann Apr 16 '18 at 8:48