MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

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

  • To: mathgroup at smc.vnet.net
  • Subject: [mg118163] Re: Coloring curves: not as simple as it sounds..
  • From: Jean-Michel Di Nicola <jeanmichel.dinicola at gmail.com>
  • Date: Fri, 15 Apr 2011 03:54:54 -0400 (EDT)
  • References: <io6d17$dpl$1@smc.vnet.net> <io6kj1$ffc$1@smc.vnet.net>

On Apr 14, 4:08 am, David Bailey <d... at removedbailey.co.uk> wrote:
> On 14/04/2011 09:59, 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!!!
>
> Plot looks at its argument to see if it is a list before it starts to
> evaluate it at particular points - so if the list structure is only
> apparent after evaluation, it doesn't work as required. This fixes it:
>
> Plot[Evaluate[{a x, a x^2, a x^3} /. {a -> 1}], {x, 0, 2},
>   PlotStyle -> {Red, Green, Blue}]
>
> The fact that it plotted at all, surprised me, so I did a couple of
> experiments:
>
> This plots two curves
>
> Plot[If[x<-2,x^2,{x^2,x^3}],{x,1,10}]
>
> But if the expression to be plotted only returns a list for part of the
> range, only one curve results!
>
> Plot[If[x<2,x^2,{x^2,x^3}],{x,1,10}]
>
> David Baileyhttp://www.dbaileyconsultancy.co.uk- Hide quoted text -
>
> - Show quoted text -

Chris, David,

Thank you for your useful answers.

JM


  • Prev by Date: Re: broadcasting of Equal ? (newbie question)
  • Next by Date: Re: Trignometric rules
  • Previous by thread: Re: Coloring curves: not as simple as it sounds..
  • Next by thread: Re: Coloring curves: not as simple as it sounds..