       RE: Plotting multiple functions using Map

• To: mathgroup at smc.vnet.net
• Subject: [mg24282] RE: [mg24254] Plotting multiple functions using Map
• From: Wolf Hartmut <hwolf at debis.com>
• Date: Fri, 7 Jul 2000 00:11:25 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```

> -----Original Message-----
> From:	Grischa Stegemann [SMTP:Stegemann at Physik.TU-Berlin.DE]
To: mathgroup at smc.vnet.net
> Sent:	Thursday, July 06, 2000 5:11 AM
> To:	mathgroup at smc.vnet.net
> Subject:	[mg24254] Plotting multiple functions using Map
>
> Dear group
>
> I have a two parameter function, e.g.
> In:= f[x_,y_]:=x+y
>
> Now I would like to plot f[x,y1],f[x,y2],... within the same chart.
> Usually you would try something like this:
> In:= Plot[{f[x,1],f[x,2],f[x,3]},{x,-3,3}]
>
> Since my list of y's is pretty long I tried this:
> In:= ylist={1,2,3};
>         Plot[Map[f[x,#1]&,ylist],{x,-3,3}]
>
> but Mathematica complains
>   Plot::"plnr": (f[x, #1]&)/@ylist is not a machine-size real number
>                 at x=-2.9999997
>
> On the other hand we have
> In:= Map[f[x,#1]&,ylist]
> Out= {1 + x, 2 + x, 3 + x}
> and
> In:= Plot[{1 + x, 2 + x, 3 + x},{x,-3,3}]
> of course works as expected.
>
> Where is my mistake?
> --
>                          Grischa
>
> ----------------------------------------------------------------------
> Grischa Stegemann                       Technische Universitaet Berlin
> email: Stegemann at physik.tu-berlin.de
>
> *** We are here on Earth to do good for others.
> *** What the others are here for, I do not know.  (W.H. Auden)
>
[Wolf Hartmut]

Grischa,

you nearly got it, just do inside of Plot, what you did outside: Evaluate
Map, so

In:=
Plot[Evaluate[Map[f[x, #1] &, ylist]], {x, -3, 3}]

does it. You certainly have more alternatives, e.g.

In:=
Show[Block[{\$DisplayFunction = Identity},
Plot[f[x, #1], {x, -3, 3}] & /@ ylist]]

Kind regards, Hartmut

```

• Prev by Date: Re: Plotting multiple functions using Map
• Next by Date: Re: LogPlot != Plot[Log]
• Previous by thread: Re: Plotting multiple functions using Map
• Next by thread: Re: Plotting multiple functions using Map