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


Groups > comp.soft-sys.math.mathematica > #1701

Re: Coloring curves: not as simple as it sounds..

From Murray Eisenberg <murray@math.umass.edu>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Coloring curves: not as simple as it sounds..
Date 2011-04-15 07:55 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <io8tla$q9c$1@smc.vnet.net> (permalink)

Show all headers | View raw


This has been discussed before -- multiple times, probably, in this 
list.Search the comp.soft-sys.math.mathematica archives for the "plot 
colors".

In brief, the difference you get is because Plot has Attribute HoldAll. 
  The work-around is to wrap your table with Evaluate:

   Plot[Evaluate[{a x, a x^2, a x^3} /. {a -> 1}], {x, 0, 2},
  PlotStyle -> {Red, Green, Blue}]

On 4/14/2011 4:49 AM, Jean-Michel Di Nicola wrote:
> All,
>
> I have a question that looks fairly trivial, but I cannot solve it....
> Please help!
>
> Thanks, JM
>
> Here is a simplified toy example.
> When I type
> Plot[{a x /. {a ->  1}, a x^2 /. {a ->  1}, a x^3 /. {a ->  1}}, {x, 0,
>    2}, PlotStyle ->  {Red, Green, Blue}]
> I get 3 curves with different colors.
>
> Well, when I type
> Plot[{a x, a x^2, a x^3} /. {a ->  1}, {x, 0, 2},
>   PlotStyle ->  {Red, Green, Blue}]
> I get 3 curves but they are all blue, WHY?
>
> However, when I evaluate {a x /. {a ->  1}, a x^2 /. {a ->  1}, a x^3 /.
> {a ->  1} and {a x, a x^2, a x^3} /. {a ->  1}, they both give the same
> result....{x, x^2, x^3}.
>
> Thank you for your help!!!
>

-- 
Murray Eisenberg                     murray@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Coloring curves: not as simple as it sounds.. Murray Eisenberg <murray@math.umass.edu> - 2011-04-15 07:55 +0000

csiph-web