|
[Date Index]
[Thread Index]
[Author Index]
Re: When is a List not a List?
- To: mathgroup at smc.vnet.net
- Subject: [mg90959] Re: When is a List not a List?
- From: "news.individual.net" <noemail at noemail.com>
- Date: Fri, 1 Aug 2008 02:57:54 -0400 (EDT)
- References: <g6rntk$7kj$1@smc.vnet.net>
"AES" <siegman at stanford.edu> wrote in message
news:g6rntk$7kj$1 at smc.vnet.net...
> g[x_, n_] := x^n
> FullForm[Table[g[x, n], {n, 1, 2}]]
> FullForm[{g[x, 1], g[x, 2]}]
> Plot[{g[x, 1], g[x, 2]}, {x, 0, 1}, PlotStyle -> {Red, Blue}]
> Plot[Table[g[x, n], {n, 1, 2}], {x, 0, 1}, PlotStyle -> {Red, Blue}]
>
> The FullForm[]s are identical. One Plot[] has red and blue curves; the
> other has two blue curves.
>
> Quirky!
>
Dear Pr. Siegman,
This is indeed strange. It is related to the HoldAll attribute of Plot since
by forcing the evaluation with
Plot[Table[g[x, n], {n, 1, 2}] // Evaluate, {x, 0, 1},
PlotStyle -> {Red, Blue}]
one gets two colors.
By looking at the FullForm of the resulting graphics, with
g1=Plot[{g[x, 1], g[x, 2]}, {x, 0, 1}, PlotStyle -> {Red, Blue}]
we have for g1[[1]] a structure like
{{{}, {},
{Hue[0.67, 0.6, 0.6], RGBColor[1, 0, 0], Line[{(*data points*)}]},
{Hue[0.906068, 0.6, 0.6], RGBColor[0, 0, 1], Line[{(* data points *)}]}
}}
which gives the two lines with different colors.
For
g2=Plot[Table[g[x, n], {n, 1, 2}], {x, 0, 1}, PlotStyle -> {Red, Blue}]
we have for g2[[1]]
{{{}, {},
{Hue[0.67, 0.6, 0.6], RGBColor[1, 0, 0], RGBColor[0, 0, 1],
Line[{(* data points *)}],
Line[{(* data points *)}]}
}}
where the two color directives are present, but the first line data is
provided after the second color directive and is thus drawn with the same
color as the second one...
This is indeed quite strange.
Guy Lamouche
Prev by Date:
Re: When is a List not a List?
Next by Date:
Re: Performance of Array Addition
Previous by thread:
Re: When is a List not a List?
Next by thread:
Re: Re: When is a List not a List?
|