Re: Plot question

*To*: mathgroup at smc.vnet.net*Subject*: [mg81012] Re: Plot question*From*: Szabolcs <szhorvat at gmail.com>*Date*: Sat, 8 Sep 2007 03:45:57 -0400 (EDT)*Organization*: University of Bergen*References*: <fbq6ek$ebr$1@smc.vnet.net>

Tony Harker wrote: > I still don't understand this. I can see that the HoldAll attribute means > that Mathematica doesn't know before it starts the plotting that it really > has three things to plot, but I don't see why this in some way overrides the > option that says that, whatever is plotted, the first plot should be in Red > etc. At what stage is the information in the option jettisoned? It simply works this way. It chooses the number of styles to be used before evaluating its argument. But as plotting begins, it notices that "oops ... there is actually more than one curve to be plotted". I agree, it is confusing. IMO the Mathematica 5.2 behaviour was much better (and more transparent). Checking the length of the argument *after* it has been evaluated with a numerical value (the Mathematica 6 way) is not going to be more reliable anyway, just think about things like If[x < 1, {x, x^2}, {x, x^2, x^3}]. In many of those cases where Mathematica 5.2 _requires_ Evaluate in Plot, it is a good idea to use Evaluate in Mathematica 6 too, for performance reasons. For example, let f[x_] = {x, x^2}. If Plot receives f[x] directly, it cannot compile it, and it will need to do an extra evaluation for every data point. > As a supplementary, can you give an example in which wrapping the first > argument of Plot in Evaluate causes problems? Just think about examples when one must use := instead of = . x = 1.; Plot[x^2 // Evaluate, {x, 0, 10}]