Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #5638 > unrolled thread
| Started by | Alexei Boulbitch <Alexei.Boulbitch@iee.lu> |
|---|---|
| First post | 2011-10-14 09:56 +0000 |
| Last post | 2011-10-15 10:03 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
Re: Plot function with two arguments Alexei Boulbitch <Alexei.Boulbitch@iee.lu> - 2011-10-14 09:56 +0000
Re: Plot function with two arguments "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-10-15 10:03 +0000
| From | Alexei Boulbitch <Alexei.Boulbitch@iee.lu> |
|---|---|
| Date | 2011-10-14 09:56 +0000 |
| Subject | Re: Plot function with two arguments |
| Message-ID | <j79109$i3b$1@smc.vnet.net> |
"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
f[x_, k_] := (k*x^2 - x)/(x - k)
Plot[Evaluate@Table[f[x, k], {k, -3, 3}], {x, -20, 20}]
Remove Evaluate, and all the curves will be the same color.
Bobby
On Wed, 12 Oct 2011 02:43:01 -0500, Momo K <momok1994 at googlemail.com>
wrote:
> Hello,
>
> I want to plot the function f. It is defined as followed:
>
> f[x_, k_] := (k*x^2 - x)/(x - k)
>
> As you see, it takes two arguments. In fact it shall represent a family
> of
> curves, but I didn't find any way different to this to define one.
>
> My aim is to plot the function by plot firstly f[x, -3], then f[x, -2],
> f[x,
> -1], f[x, 0], ...
> Is there a way to do this automatically without typing every single
> function
> with k adjusted. I imagined something like {{x,-20,20}, {k,-3,3}} or so.
>
> Many thanks
> and best regards
>
> Momo
Alexei BOULBITCH, Dr., habil.
IEE S.A.
ZAE Weiergewan,
11, rue Edmond Reuter,
L-5326 Contern, LUXEMBOURG
Office phone : +352-2454-2566
Office fax: +352-2454-3566
mobile phone: +49 151 52 40 66 44
e-mail: alexei.boulbitch@iee.lu<mailto:alexei.boulbitch@iee.lu>
[toc] | [next] | [standalone]
| From | "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> |
|---|---|
| Date | 2011-10-15 10:03 +0000 |
| Message-ID | <j7blpd$32t$1@smc.vnet.net> |
| In reply to | #5638 |
On Fri, 14 Oct 2011 10:56:25 +0100, Alexei Boulbitch
<Alexei.Boulbitch@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.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web