Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #1920 > unrolled thread

Re: and color via PlotStyle

Started byAES <siegman@stanford.edu>
First post2011-04-30 09:51 +0000
Last post2011-05-02 10:51 +0000
Articles 3 — 3 participants

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: and color via PlotStyle AES <siegman@stanford.edu> - 2011-04-30 09:51 +0000
    Re: and color via PlotStyle Helen Read <readhpr@gmail.com> - 2011-05-01 10:22 +0000
    Re: and color via PlotStyle Dushan Mitrovich <dushanm@spinn.net> - 2011-05-02 10:51 +0000

#1920 — Re: and color via PlotStyle

FromAES <siegman@stanford.edu>
Date2011-04-30 09:51 +0000
SubjectRe: and color via PlotStyle
Message-ID<ipgm2t$8op$1@smc.vnet.net>
In article <ipe7mj$r1o$1@smc.vnet.net>,
 Bill Rowe <readnews@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?

[toc] | [next] | [standalone]


#2008

FromHelen Read <readhpr@gmail.com>
Date2011-05-01 10:22 +0000
Message-ID<ipjc8n$j1l$1@smc.vnet.net>
In reply to#1920
On 4/30/2011 5:51 AM, AES wrote:
> In article<ipe7mj$r1o$1@smc.vnet.net>,
>   Bill Rowe<readnews@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 =AD=AD but has never had to encounter the concepts of Hold or
> Evaluate.
>
> After all, having a rudimentary understanding of Plot, PlotStyle, the \=2E
> syntax, and lists (which are all relatively simple, understandable,
> learnable commands that do familiar things) permits this user to do many
> useful tasks =AD=AD 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?

Oh, please. Nobody needs to go through all that "before they could start 
plotting Lists using  Plot".

My beginning students plot lists all the time. Normally they do it by
defining functions first, for whatever it is they are plotting.

f[x_]:=x
g[x_]:=x^2
h[x_]:=x^3

Plot[{f[x],g[x],h[x]},{x,0,2},PlotStyle -> {Red, Green, Blue}]

(Although actually, most of them accept the default colors and rarely
bother with PlotStyle. Either way, they will get a nice plot with each
curve a different color.)
Then they might go back and edit f[x], g[x], and h[x] to make them 2x,
2x^2, 2x^3, or what have you, and re-evaluate. A little later on (when
not exactly a newbie anymore), they might try something along these
lines, which also produces different colored curves.


Manipulate[
  Plot[{a x, a x^2, a x^3}, {x, -2, 2},
   PlotStyle -> {Red, Green, Blue}, PlotRange -> {-10, 10}], {a, -5, 5,
    1, Appearance -> "Labeled"}]


I have *never* seen a beginner try to use anything remotely like
{ a x, a x^2, a x^3}/. {a ->  1} inside a Plot. But if they did, it
would not bother anybody. They would either ask why it came out that
way, or try a different way of doing it, or ignore it and move on. It's
just not a big deal.

But I don't even show them the /. notation until there is a real need
for it. I teach them about defining functions from day one.


--
Helen Read
University of Vermont

[toc] | [prev] | [next] | [standalone]


#2022

FromDushan Mitrovich <dushanm@spinn.net>
Date2011-05-02 10:51 +0000
Message-ID<ipm2al$54s$1@smc.vnet.net>
In reply to#1920
Helen Read wrote:
> On 4/30/2011 5:51 AM, AES wrote:
>    
>> In article<ipe7mj$r1o$1@smc.vnet.net>,
>>    Bill Rowe<readnews@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 =AD=AD but has never had to encounter the concepts of Hold or
>> Evaluate.
>>
>> After all, having a rudimentary understanding of Plot, PlotStyle, the \=2E
>> syntax, and lists (which are all relatively simple, understandable,
>> learnable commands that do familiar things) permits this user to do many
>> useful tasks =AD=AD 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?
>>      
> Oh, please. Nobody needs to go through all that "before they could start
> plotting Lists using  Plot".
>
> My beginning students plot lists all the time. Normally they do it by
> defining functions first, for whatever it is they are plotting.
>
> f[x_]:=x
> g[x_]:=x^2
> h[x_]:=x^3
>
> Plot[{f[x],g[x],h[x]},{x,0,2},PlotStyle ->  {Red, Green, Blue}]
>
> (Although actually, most of them accept the default colors and rarely
> bother with PlotStyle. Either way, they will get a nice plot with each
> curve a different color.)
> Then they might go back and edit f[x], g[x], and h[x] to make them 2x,
> 2x^2, 2x^3, or what have you, and re-evaluate. A little later on (when
> not exactly a newbie anymore), they might try something along these
> lines, which also produces different colored curves.
>
>
> Manipulate[
>    Plot[{a x, a x^2, a x^3}, {x, -2, 2},
>     PlotStyle ->  {Red, Green, Blue}, PlotRange ->  {-10, 10}], {a, -5, 5,
>      1, Appearance ->  "Labeled"}]
>
>
> I have *never* seen a beginner try to use anything remotely like
> { a x, a x^2, a x^3}/. {a ->   1} inside a Plot. But if they did, it
> would not bother anybody. They would either ask why it came out that
> way, or try a different way of doing it, or ignore it and move on. It's
> just not a big deal.
>
> But I don't even show them the /. notation until there is a real need
> for it. I teach them about defining functions from day one.
>
> --
> Helen Read
> University of Vermont
>    

So far everybody has been talking about whether the behavior is reasonable
or unreasonable to expect, but nobody has (AFAIK) done the obvious, namely
stated the solution to the question: Just how does one get 
differently-colored curves when using the '/.{a->1}'?

I am a near-beginner, have run into the problem myself, and have been reading
the thread hoping to learn the solution.  No luck.

- Dushan

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web