Re: weird behavior when plotting multiple functions in 6.0
- To: mathgroup at smc.vnet.net
- Subject: [mg76089] Re: [mg76050] weird behavior when plotting multiple functions in 6.0
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Wed, 16 May 2007 05:25:49 -0400 (EDT)
- References: <200705150859.EAA17134@smc.vnet.net>
On 15 May 2007, at 17:59, Roman wrote: > Hello all: > > When I plot > Plot[{Sin[x], Cos[x]}, {x, 0, 4*Pi}] > I get two curves: one blue, one red. > > But when I do > f[x_] = {Sin[x], Cos[x]}; > Plot[f[x], {x, 0, 4*Pi}] > both curves are blue. It is as if at some level Mathematica does not > understand that I'm actually plotting two curves at a time, and uses > the first color specification (blue) for both curves. > > This is particularly annoying when you want to play with plot styles, > for example filling instructions, like > Filling -> {1 -> -1, 2 -> 1} > which works in the first example but not in the second one. > > Has anyone figured out a workaround for this one? > > Thanks! > Roman. > > This is completely reasonable. Unless Mathemaitca sees and explicit List as the Head of the argument to be plotted it will use the algorithm for plotting a single function. Actually, this shows an interesting change compared with Mathematica 5.2. In Mathematica 5.2 your code will produce no plot at all: but only error messages. In Mathematica 6 you actually get a plot of two fucntions but colored inthe same way. In both versions the correct thing to do is: f[x_] = {Sin[x], Cos[x]}; Plot[Evaluate[f[x]], {x, 0, 4*Pi}] Andrzej Kozlowski
- References:
- weird behavior when plotting multiple functions in 6.0
- From: Roman <rschmied@gmail.com>
- weird behavior when plotting multiple functions in 6.0