MathGroup Archive 2011

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

Search the Archive

Re: Workaround for Plot[ ] and color via PlotStyle

  • To: mathgroup at smc.vnet.net
  • Subject: [mg118470] Re: Workaround for Plot[ ] and color via PlotStyle
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Fri, 29 Apr 2011 07:31:17 -0400 (EDT)

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

Bobby

On Thu, 28 Apr 2011 05:34:23 -0500, Christopher O. Young  
<cy56 at comcast.net> 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
>
> Plot[
>  {
>    a x,
>    a x^2,
>    a x^3
>    } /. {a -> 1},
> {x, 0, 2},
>
> PlotStyle -> {Red, Green, Blue}
>  ]
>
>
>   just produces blue plots.
>
> So I tried to figure out to work from the fully written-out form:
>
> Show[
>  Plot[y = x, {x, -5, 5}, PlotStyle -> {Thick, Red}],
>  Plot[y = x^2, {x, -5, 5}, PlotStyle -> {Thick, Yellow}],
>  Plot[y = x^3, {x, -5, 5}, PlotStyle -> {Thick, Blue}]
>  ]
>
>
> The above works fine, but is very redundant.
>
> A Table will streamline the above commands:
>
> Show[
>  Table[
>   Plot[
>    y = x^k, {x, -5, 5},
>    PlotStyle -> {Thick, Hue[0.5 (k - 1)/3]}
>    ],
>   {k, 1, 3}]
>  ]
>
>
> Does anybody know how to go through a list of colors via the k index?
>
> At any rate, if you're a big fan of postfix notation, the following can  
> be
> rewritten in stages, as:
>
> Table[
>   Plot[
>    y = x^k, {x, -5, 5},
>    PlotStyle -> {Thick, Hue[0.5 (k - 1)/3]}
>    ],
>   {k, 1, 3}
>   ] // Show
>
>
>
>
> Plot[
>    y = x^k, {x, -5, 5},
>    PlotStyle -> {Thick, Hue[0.5 (k - 1)/3]}
>    ]~Table~{k, 1, 3}\
>     // Show
>
>
>
> And, finally:
>
> (y = x^k //
>       Plot[
>         #, {x, -5, 5},
>         PlotStyle -> {Thick, Hue[0.5 (k - 1)/3]}
>         ] &)\
>    ~Table~{k, 1, 3}\
>     // Show
>
>
>


-- 
DrMajorBob at yahoo.com


  • Prev by Date: Re: Expected value of the Geometric distribution
  • Next by Date: Re: Expected value of the Geometric distribution
  • Previous by thread: Re: Workaround for Plot[ ] and color via PlotStyle
  • Next by thread: Re: Workaround for Plot[ ] and color via PlotStyle