0
$\begingroup$

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[0] == 1, y[0] == 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}]]

enter image description here

What I want to produce is something like

enter image description here

I'm looking for a simple implementation, in which I could perform all the plot options (filling, framing etc.).

$\endgroup$
  • $\begingroup$ @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. $\endgroup$ – jarhead Apr 16 '18 at 8:44
3
$\begingroup$
s = NDSolve[{x'[t] == -x[t] + 2 y[t], y'[t] == -4 y[t] x[t], 
    x[0] == 1, y[0] == 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}]}]

enter image description here

$\endgroup$
1
$\begingroup$

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[0]==1,y[0]==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}]

enter image description here

pic /.{ Line[pts_]:>Line[Reverse/@ pts], HoldPattern[PlotRange->pr_]:>(PlotRange->Reverse@pr)}

enter image description here

$\endgroup$
0
$\begingroup$
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}]

enter image description here

$\endgroup$
  • $\begingroup$ Thanks for answering, but here the plot is not reversed/transposed $\endgroup$ – jarhead Apr 16 '18 at 8:42
  • $\begingroup$ Sorry, now I got your question $\endgroup$ – Ulrich Neumann Apr 16 '18 at 8:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.