Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #1996
| From | Bill Rowe <readnews@sbcglobal.net> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: and color via PlotStyle |
| Date | 2011-04-29 11:33 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <ipe7mj$r1o$1@smc.vnet.net> (permalink) |
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 comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: and color via PlotStyle Bill Rowe <readnews@sbcglobal.net> - 2011-04-29 11:33 +0000
csiph-web