Re: Plotting multiple outputs from cpu intensive functi

• To: mathgroup at smc.vnet.net
• Subject: [mg16875] Re: [mg16745] Plotting multiple outputs from cpu intensive functi
• From: "Richard W. Klopp" <rwklopp at unix.sri.com>
• Date: Mon, 5 Apr 1999 02:24:18 -0400
• Organization: SRI International
• References: <7e1c75\$bb6@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Actually, you can sort of hijack the Plot[] adaptive sampling routines
using the following. I learned this in a Mathematica course that I took.
I don't know where they got it. It's great for extracting plot points
for plotting in a more plotting-friendly environment such as Igor or
Sigmaplot.

AdaptiveSample[f_, {var_, min_, max_}, opts___] :=

Block[{plot, cmp, pts, bend, div, sampler},

sampler = Plot; If[MatchQ[Hold[f], Hold[{_, _}]],

sampler = ParametricPlot];

{cmp, pts, bend, div} =

{Compiled, PlotPoints, MaxBend, PlotDivision} /. {opts} /.

Options[sampler]; plot =

sampler[f, {var, min, max}, Compiled -> cmp, PlotPoints -> pts,

MaxBend -> bend, PlotDivision -> div, Axes -> none, Frame ->
False,

DisplayFunction -> Identity, Prolog -> {}, Epilog -> {}];

First /@ Cases[First[plot], _Line, Infinity]]

jns1 wrote:
>
> The best would be if the adaptive choices of x for f (with g evaluated
> and stored also) could be stored as starting points for the adaptive
> values for g. Then, fewer extra evaluations of g (and unavoidably, f)
> would be needed. This certainly does not seem difficult to program
> outside of the Plot function and then use ListPlot on the result. It
> would be even easier if the algorithm that Mathematica uses inside Plot
> to choose points was available. Then it could be modified with your own
> MaxBend, PlotDivision, PlotPoints arguments for this multiple function
> case.
>
> See, this is an argument for Open Source Mathematica!
>
> Joel
>
> Allan Hayes wrote:
> >
> > Ted,
> > One problem is that Plot[{f,g}, {x,a,b}] makes adaptive choices of x for f
> > and then independently for g. For this and maybe for other reasons the
> > remembered values may not be the ones needed. One way out might be to make
> > interpolating functions from the remembered values (a linear interpolation
> > would likely be sufficient). Of course we might then have to deal with
> > evaluating outside the data range.
> >
> > Allan

```

• Prev by Date: Re: How display negative contours with dashed lines?
• Next by Date: Re: How display negative contours with dashed lines?
• Previous by thread: Re: Plotting multiple outputs from cpu intensive functi
• Next by thread: FW: Plotting multiple outputs from cpu intensive functi