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


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

Re: Bug with map in conjuntion with plotstyle?

From Bob Hanlon <hanlonr@cox.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Bug with map in conjuntion with plotstyle?
Date 2011-04-07 12:07 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <ink9dj$gca$1@smc.vnet.net> (permalink)

Show all headers | View raw


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


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


Thread

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

csiph-web