Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #1996 > unrolled thread
| Started by | Bill Rowe <readnews@sbcglobal.net> |
|---|---|
| First post | 2011-04-29 11:33 +0000 |
| Last post | 2011-04-29 11:33 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
Re: and color via PlotStyle Bill Rowe <readnews@sbcglobal.net> - 2011-04-29 11:33 +0000
| From | Bill Rowe <readnews@sbcglobal.net> |
|---|---|
| Date | 2011-04-29 11:33 +0000 |
| Subject | Re: and color via PlotStyle |
| Message-ID | <ipe7mj$r1o$1@smc.vnet.net> |
On 4/28/11 at 6:34 AM, cy56@comcast.net (Christopher O. Young) wrote:
>As a previous poster showed, Plot is a little inconsistent when it
>comes to mapping colors via PlotStyle.
>Plot[
>{ a x /. {a -> 1}, a x^2 /. {a -> 1}, a x^3 /. {a -> 1}
>},{x, 0, 2},PlotStyle -> {Red, Green, Blue}]
>works OK but
This works as you are expecting only because the argument to
Plot is an explicit list. This is the only case where Plot uses
multiple colors.
>Plot[{ a x, a x^2, a x^3}/. {a -> 1},{x, 0, 2},
>PlotStyle -> {Red, Green, Blue}]
>just produces blue plots.
Exactly as it should. Plot always evaluates its arguments by
first substituting a numeric value for the independent variable
and only after that is the expression evaluated. The consequence
it for the argument above, Plot does not see a list of
expressions. Instead it sees a list of numeric values which is
treated as a single function with multiple values and
consequently plotted in a single color.
You can force evaluation of the expression before a numeric
value is substituted for the plot variable by using Evaluate.
That is doing
Plot[Evaluate[{ a x, a x^2, a x^3}/. {a -> 1}],{x, 0, 2}]
will result in Plot seeing an explicit list of expressions which
will get plotted in different colors.
There is no inconsistency in the behavior of Plot. The behavior
I am describing is well documented even if not always well understood.
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web