Re: and color via PlotStyle
- To: mathgroup at smc.vnet.net
- Subject: [mg118501] Re: and color via PlotStyle
- From: AES <siegman at stanford.edu>
- Date: Sat, 30 Apr 2011 05:51:12 -0400 (EDT)
- References: <ipe7mj$r1o$1@smc.vnet.net>
In article <ipe7mj$r1o$1 at smc.vnet.net>,
Bill Rowe <readnews at sbcglobal.net> wrote:
>
> >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.
The statement "Exactly as it _should_" is open to discussion here.
Consider an "ordinary user" (a user attempting to use Mathematica to do
some simple but useful task) who is at a level of sophistication where
he/she understands the Plot command; how to use it to plot a List of
functions {f1,f2,f3}; the use of simple PlotStyles; and the use of the
"\." syntax but has never had to encounter the concepts of Hold or
Evaluate.
After all, having a rudimentary understanding of Plot, PlotStyle, the \.
syntax, and lists (which are all relatively simple, understandable,
learnable commands that do familiar things) permits this user to do many
useful tasks and to do themwithout ever having any interaction with
the much more complex and arcane (and much less standard or familiar in
ordinary life) concepts of Hold and Evaluate.
This mythical user might then well be forgiven for thinking that the two
commands
a = 1;
Plot[{ a x, a x^2, a x^3}, {x, 0, 2},
PlotStyle -> {Red, Green, Blue}]
Plot[{ a x, a x^2, a x^3}/. {a -> 1}, {x, 0, 2},
PlotStyle -> {Red, Green, Blue}]
_should_ do exactly the same thing, except that the first form will also
obviously leave a assigned the value 1 in subsequent cells.
But of course, this is not what happens, and so the user who uses the
second form (perhaps doing so for compactness, or perhaps wanting to
make a test Plot of their List without setting a to a fixed value)
encounters another of the copious supply of puzzling Mathematica
"gotchas".
I'm not arguing that this outcome is in some sense "wrong", or in any
way a bug. There may be -- probably are -- deep reasons, buried deep in
the logic and design of Mathematica, as to why Plot has to function in
this way (or maybe an unnecessary design decision was made that Plot
would function in this way to simplify other aspects of Mathematica
programming?).
But it's still unfortunate that it does operate this way. Would you
(and maybe Helen ??? in Washington) really want to argue that high
school students, or freshman students in college, should have to first
go through a tutorial in Hold and Evaluate (and maybe also HoldAll,
HoldFirst, NHoldAll, HoldAllComplete, HoldRest, SequenceHold, Extract,
and Unevaluated) before they could start plotting Lists using Plot?