MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Plotting multiple functions using Map

  • To: mathgroup at smc.vnet.net
  • Subject: [mg24302] RE: [mg24254] Plotting multiple functions using Map
  • From: "David Park" <djmp at earthlink.net>
  • Date: Fri, 7 Jul 2000 00:11:44 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com


> -----Original Message-----
> From: Grischa Stegemann [mailto:Stegemann at Physik.TU-Berlin.DE]
To: mathgroup at smc.vnet.net
> Dear group
>
> I have a two parameter function, e.g.
> In[1]:= 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[2]:= 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[3]:= 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
>

Grischa,

You idea is right on the mark. You only forgot that Plot has the attributes
HoldAll, so you need to Evaluate to obtain the desired list of functions.

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

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/



  • Prev by Date: printing 2D graphics with a known scale
  • Next by Date: lancon
  • Previous by thread: Re: Plotting multiple functions using Map
  • Next by thread: Re: Plotting multiple functions using Map