Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 1 down vote accepted


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}]
share|improve this answer
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? – xslittlegrass May 1 '13 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. – xslittlegrass May 1 '13 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}]
share|improve this answer
Thanks. That's very helpful. – xslittlegrass May 1 '13 at 20:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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