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


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

Re: Bug with map in conjuntion with plotstyle?

Started byBob Hanlon <hanlonr@cox.net>
First post2011-04-07 12:07 +0000
Last post2011-04-07 12:07 +0000
Articles 1 — 1 participant

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


Contents

  Re: Bug with map in conjuntion with plotstyle? Bob Hanlon <hanlonr@cox.net> - 2011-04-07 12:07 +0000

#1526 — Re: Bug with map in conjuntion with plotstyle?

FromBob Hanlon <hanlonr@cox.net>
Date2011-04-07 12:07 +0000
SubjectRe: Bug with map in conjuntion with plotstyle?
Message-ID<ink9dj$gca$1@smc.vnet.net>
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@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


[toc] | [standalone]


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


csiph-web