# How to manipulate plot range with fixed axes

I want to achieve something like this

Manipulate[Plot[Sin[x], {x, 0, r}, PlotRange -> {{0, 10}, {-1, 1}}], {r, 0.1, 10}]


but my function in place of Sin is an expensive function, and since what I want is only change of plot range, there is no need to recalculate the values every time. So I try this

p = Plot[Sin[x], {x, 0, 10}];
Manipulate[Show[p, PlotRange -> {{0, r}, {-1, 1}}], {r, 0.1, 10}]


but the plot axes is changing as I change r. So is it possible to manipulate the plot range of a plot with a fixed axes, without reevaluate it every time?

Also,

f = FunctionInterpolation[Sin[x], {x, 0, 2 Pi}];
Manipulate[ Plot[f[x], {x, 0, r}, PlotRange -> {{0, 2 Pi}, {-1, 1}}], {r, 0.1, 2 Pi}]

• Thanks, but my function returns a list, and it seems FunctionInterpolation doesn't work this way: f = FunctionInterpolation[{Sin[x],Cos[x]}, {x, 0, 2 Pi}]; . Do you know how to deal with this? May 1, 2013 at 2:23
• OK, I think this works:f = Function[{t},{(FunctionInterpolation[Sin[x], {x, 0, 2 Pi}])[t],(FunctionInterpolation[Cos[x], {x, 0, 2 Pi}])[t]} Thanks for the help. May 1, 2013 at 2:34

How about pulling out the data in the plot and making it into a ListPlot. You can then vary how much of the list you plot but keep the plot range the same.

p = Plot[Sin[x], {x, 0, 10}];
pdata=p[[1, 1, 3, 2, 1]];
Manipulate[ListLinePlot[pdata[[1 ;; m]],PlotRange -> {{0, 10}, {-1, 1}}], {m, 1, Length[pdata],1}]