# How to rotate the curve but not the axes?

I have a such graphic:

data = {{0, 5}, {1.9, 7.5}, {0, 12}, {-5, 15.5}, {-1.2, 33.4}};
p=Plot[Interpolation[Reverse /@ data, x, InterpolationOrder -> 2], {x,
0, 55}, Epilog -> {Red, PointSize[.01], Point[Reverse /@ data]}] But acutually this picture is expected(except that ticks label rotated) Note the interpolation method should be used,but not the fit method here.How to get such graphic?

## Update:

I get a lot solution in following answers.But I realize if I have a option Filling -> Axis in my p.All solution cannot work anymore. ## 4 Answers

p = Plot[Interpolation[Reverse /@ data, x, InterpolationOrder -> 2], {x, 0, 55},
Epilog -> {Red, PointSize[.01], Point[Reverse /@ data]}, Filling -> Axis]


You can post-process p to rotate the graphics primitives:

Show[Normal[p] /. prim : _Line | _Point | _Polygon :>
GeometricTransformation[prim, RotationTransform[Pi/2]],
PlotRange -> All, AspectRatio -> GoldenRatio] • Congratulation for 100K. :) And I realize if we have a option Filling -> Axis in p.The rotate graphic cannot include anymore? – yode Jan 14 '17 at 23:35
• Thank you @yode. Please the new version to deal with Filling. – kglr Jan 15 '17 at 1:52

This is pretty neat:

data = {{0, 5}, {1.9, 7.5}, {0, 12}, {-5, 15.5}, {-1.2, 33.4}};
iFun = Interpolation[Reverse[data, 2], InterpolationOrder -> 2];
ParametricPlot[Cross[{x, iFun[x]}], {x, 0, 55}, AspectRatio -> GoldenRatio,
Epilog -> {Directive[Red, PointSize[.01]],
Point[Cross /@ Reverse[data, 2]]}] I'll leave fiddling with the ticks up to you.

data = {{0, 5}, {1.9, 7.5}, {0, 12}, {-5, 15.5}, {-1.2, 33.4}};
plot = Plot[
Interpolation[Reverse /@ data, x, InterpolationOrder -> 2], {x, 0,
55}, Epilog -> {Red, PointSize[.01], Point[Reverse /@ data]}];

Graphics[
Rotate[{#, Epilog /. {##2}}, Pi/2, {0, 0}],
AspectRatio -> GoldenRatio, Axes -> True
] & @@ plot For your updated example:

data = {{0, 5}, {1.9, 7.5}, {0, 12}, {-5, 15.5}, {-1.2, 33.4}};

p = Plot[Interpolation[Reverse /@ data, x, InterpolationOrder -> 2], {x, 0, 55},
Epilog -> {Red, PointSize[.01], Point[Reverse /@ data]}, Filling -> Axis]


A variation of axisFlip from How can I transpose x and y axis on a Plot? and Plot time along the y-axis?

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

Show[axisRotate@p, AspectRatio -> GoldenRatio/1, PlotRange -> All] Tick labels still show negative values however. If we are going to fiddle with tick labels another approach opens up: just counter-rotate the labels:

rR = {#, Rotate[#, -90 °]} &;

Show[p, Ticks -> {rR /@ Range[10, 50, 10], rR /@ Range[20, 60, 20]}] //
Rotate[#, 90 °] & This is not as nice for further processing and use so I favor the first method.

• An alternative is to use GeometricTransformation, as in: p /. Graphics[g_, r___] :> Graphics[GeometricTransformation[g, RotationTransform[Pi/2]], PlotRange -> All, AspectRatio -> GoldenRatio, r] – Carl Woll Jan 15 '17 at 0:38
• @CarlWoll That certainly could be useful for more complicated transformations, but is there any advantage in this case over Dot? – Mr.Wizard Jan 15 '17 at 0:39
• It is useful because you don't have to have consider every possible Graphics primitive, e.g., Arrow, Polygon, etc. The OP example only has Point and Line, so using explicit rules for these objects works just as well. – Carl Woll Jan 15 '17 at 0:53
• @CarlWoll I overlooked that part of your code entirely. Thanks! – Mr.Wizard Jan 15 '17 at 0:55
• @CarlWoll Your method misses the Epilog graphics which is undesirable for the example at hand. What solution do you propose for that? One could target Epilog expressly but I wonder if there is a more general way in the spirit of that replacement rule. – Mr.Wizard Jan 15 '17 at 16:00