Re: Plotting multiple functions using Map
- To: mathgroup at smc.vnet.net
- Subject: [mg24291] Re: [mg24254] Plotting multiple functions using Map
- From: Matt.Johnson at autolivasp.com
- Date: Fri, 7 Jul 2000 00:11:32 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Per Section 1.9.1: There are, however, some cases in which it is much better to have Mathematica evaluate f before it starts to make the plot. A typical case is when f is actually a command that generates a table of functions. You want to have Mathematica first produce the table, and then evaluate the functions, rather than trying to produce the table afresh for each value of x. You can do this by typing Plot[Evaluate[ f ],{x, xmin, xmax}]. This works: Plot[Evaluate[Map[f[x,#1]&,ylist]],{x,-3,3}] -matt Grischa Stegemann <Stegemann at Physik.TU-Berlin.DE> on 07/05/2000 09:10:36 PM Subject: [mg24291] [mg24254] Plotting multiple functions using Map 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 On the other hand we have In[4]:= Map[f[x,#1]&,ylist] Out[4]= {1 + x, 2 + x, 3 + x} and In[5]:= 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)