Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

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

Search the Archive

Re: Plot function with two arguments

  • To: mathgroup at smc.vnet.net
  • Subject: [mg122115] Re: Plot function with two arguments
  • From: "Oleksandr Rasputinov" <oleksandr_rasputinov at hmamail.com>
  • Date: Sat, 15 Oct 2011 06:02:27 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <j79109$i3b$1@smc.vnet.net>

On Fri, 14 Oct 2011 10:56:25 +0100, Alexei Boulbitch  
<Alexei.Boulbitch at iee.lu> wrote:

> "Remove Evaluate, and all the curves will be the same color."
>
> Why actually it behaves this way?
>
> This:
>
> f[x_, k_] := (k*x^2 - x)/(x - k);
> Plot[Table[f[x, k], {k, -3, 3}], {x, -20, 20}]
>
> indeed yields all lines of the same colour.  However, this:
>
> lst=Table[f[x, k], {k, -3, 3}];
> Plot[lst, {x, -20, 20}]
>
> returns the lines with different colours. I would appreciate, if one  
> explains the reason For such a behaviour.
>
> Thank you, Alexei

Plot has HoldAll. By the looks of it, a check is done to see if the first  
argument has head List; if so, Plot understands that it is being given a  
list of functions and colours them accordingly. If the Head is not List,  
though (for example, in this case it would be Table), Plot treats it as a  
single, vector-valued function, with all branches plotted using the same  
style.



  • Prev by Date: Only real data
  • Next by Date: Problems plotting 3D surface and using manipulate
  • Previous by thread: Re: Plot function with two arguments
  • Next by thread: Fitting step function