Mathematica package to constrain plot evaluation time.
Download TimeConstrainedPlot.m and put it in the directory given by FileNameJoin[{$UserBaseDirectory, "Applications"}]
Plot a slow function:
<<<TimeConstrainedPlot`
slowSin[x_] := (Pause[RandomReal[0.01]]; Sin[x])
TimeConstrainedPlot[
Plot3D[slowSin[x] Cos[y], {x, 0, 10}, {y, 0, 10}],
1]
All options provided to the original plot function that are valid
for the corresponding List*Plot
will be kept. To provide more options put them in the third argument
Constrainable plot functions:
{DensityPlot, DiscretePlot,
LogLinearPlot, LogLogPlot, LogPlot,
ParametricPlot, Plot, Plot3D, PolarPlot}
Preserves sample refinement on a per-function basis:
TimeConstrainedPlot[
Plot[{Abs[x], Abs[x - 1/2]}, {x, -1, 1}]
, 1, Joined -> False]
There might not be enough time to cover the entire plot range:
TimeConstrainedPlot[Plot[slowSin[x], {x, 0, 10}], 1]
With lower PlotPoints
there is enough time to cover the range and the adaptive algorithm can start refining:
TimeConstrainedPlot[Plot[slowSin[x], {x, 0, 10}, PlotPoints -> 5], 1]
Only the refinement is time-constrained, the time to create and display the List*Plot
is not restricted.