MathGroup Archive 2002

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

Search the Archive

RE: Plot several graphs generated by Table

  • To: mathgroup at
  • Subject: [mg36441] RE: [mg36424] Plot several graphs generated by Table
  • From: "Wolf, Hartmut" <Hartmut.Wolf at>
  • Date: Sat, 7 Sep 2002 02:53:50 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

>-----Original Message-----
>From: muhnochwaaa at [mailto:muhnochwaaa at]
To: mathgroup at
>Sent: Friday, September 06, 2002 9:17 AM
>Subject: [mg36441] [mg36424] Plot several graphs generated by Table
>myArray is a list of triplets which look like {n,k,p}, where n and k
>are integers  and p is real number. repetitions in n and k are allowed
>but no two triplets ar the same.
>I define a function, myfunc[n_,pthreshold_] as follows.
>myfunc[n_,pthreshold_] := Module[{t},
>t=Max[Cases[myArray, {n, k_, p_} /; (p >= pthreshold) -> p, 2]];
>It prints the largest k for which p is greater than pthreshold for a
>given n and
>-1 if there is no such k.  The function does its job fine. 
>My problem is as follows. I would like to plot a collection of plots,
>myfunc[n,p], for 1<=n<=21 with respect to p. unfortunately the
>following does not work as desired.
>because the Table gets evaluated to numeric value (-1) before Plot is
>How could I accomplish this? Thanks in advance for all your helps.

The problem with your calculation indented is (1) to evaluate Table (within
Plot), which gives 

  {myfunc[1, p], ..., myfunc[21, p]}

but (2) *then* to prevent further evaluation of myfunc[.., p] to -1. There
are several tricks to do so, e.g. ...

Hold[Plot[toPlot, {p, 0, 1}]] /. 
      toPlot -> Table[headPlaceholder[n, p], {n, 3}] /. 
    headPlaceholder -> myfunc // ReleaseHold

...but in your case just simply prevent evaluation of myfunc[.., p] with p
being a Symbol by defining:

myfunc2[n_, pthreshold_?NumericQ] := ...


Plot[Evaluate[Table[myfunc2[n, p], {n, 21}]], {p, 0, 1}] as expected.

BTW, what do you want to read off the plot, that you didn't know from

Table[myfunc[n, 0], {n, 21}] ?

Hartmut Wolf

  • Prev by Date: Re: $Post vs. $PrePrint
  • Next by Date: Re: fourier transform time
  • Previous by thread: Re: Plot several graphs generated by Table
  • Next by thread: ListIntegrate Info.