MathGroup Archive 2009

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

Search the Archive

Re: PlotStyle will not distribute over Table

  • To: mathgroup at
  • Subject: [mg96659] Re: PlotStyle will not distribute over Table
  • From: Kresimir Kumericki <kkumer at>
  • Date: Thu, 19 Feb 2009 03:34:50 -0500 (EST)
  • References: <gngk0g$jj0$>

Thank you for your answers, but unfortunately I 
oversimplified my problem:

>    Plot[Table[Sin[a x], {a, 1, 2}], {x, 0, Pi}, 
>     PlotStyle -> {Hue[0.7], Hue[1]}]
> will have both lines with red color, while

Namely, "Sin[a x]" above is actually a MathLink-ed function
evaluated in Fortran for some value of x, and what's
worse, this Fortran in the middle of evaluation calls
back Mathematica and asks about the value of global
variable parameter "par" which should be set equal to "a"
before evaluation. I think this behaviour is equivalent
to Mathematica function, e.g.,

  fun[x_?NumericQ] := Sin[par x]

Thus, what I originally had as an argument of Table[]
instead of "Sin[a x]" above was

  (par = a; fun[x])   

Then I cannot put Evaluate[] around Table because only the
last value for par=a would be used in evaluation of all functions.
In the meantime I have solved the problem by using auxiliary
function, which serves only to break this whole evaluation in
two steps:

aux[f_, a_, x_?NumericQ] := (par = a; f[x])

Plot[Evaluate[Table[aux[fun, a, x], {a, 2}]], {x, 0, Pi}, 
 PlotStyle -> {Hue[0.7], Hue[1]}]

I don't know if this is the most elegant solution, but
it works for me.


  • Prev by Date: Re: PlotStyle will not distribute over Table
  • Next by Date: Re: Using VerticalSlider controls for Manipulate
  • Previous by thread: Re: PlotStyle will not distribute over Table
  • Next by thread: Help with Mathematica 7.0