MathGroup Archive 2011

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

Search the Archive

Re: Bug with map in conjuntion with plotstyle?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg117992] Re: Bug with map in conjuntion with plotstyle?
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Thu, 7 Apr 2011 08:07:01 -0400 (EDT)

Attributes[Plot]

{HoldAll, Protected}

Note that Plot has attribute HoldAll. Consequently, when the PlotStyles are set there is only one thing to be plotted. For Plot to see three things, you need to use Evaluate to override the HoldAll.

values = {0.5, 1.0, 2.0};

f[x_, y_] := x^2 + y

I use Green vice Yellow to make it easier for me to see.

Plot[Evaluate[{f[x, #]} & /@ values], {x, 0, 6},
 PlotStyle -> {{Red}, {Blue}, {Green}}]


Bob Hanlon

---- Jason Quinn <jason.lee.quinn at gmail.com> wrote: 

=============
values = {0.5, 1.0, 2.0};

f[x_, y_] := x^2 + y

Plot[{f[x, #]} & /@ values, {x, 0, 6}, PlotStyle -> {{Red}, {Blue},
{Yellow}}]

thing = {f[x, #]} & /@ values

Plot[thing, {x, 0, 6}, PlotStyle -> {{Red}, {Blue}, {Yellow}}]



I'm trying to use map to generate a list of functions to plot and use
PlotStyle to define the color and style of the plot. Unfortunately, it
seems like there's a bug here. When map is used with Plot, it applies
the first plotstyle to all the plots.

I think the above is a good test case. The first plot only plots red.
The second plot plots red, blue, and green as desired.

Am I misunderstanding something about plot, map, or plot style? Or is
this a bug?

Jason




  • Prev by Date: Re: Picking certain values from an array of solutions
  • Next by Date: Re: Bug with map in conjuntion with plotstyle?
  • Previous by thread: Bug with map in conjuntion with plotstyle?
  • Next by thread: Re: Bug with map in conjuntion with plotstyle?