Re: newby plotting question
- To: mathgroup at smc.vnet.net
- Subject: [mg22730] Re: newby plotting question
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Fri, 24 Mar 2000 03:27:15 -0500 (EST)
- References: <8b9orp$9dj@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
"F. Schwieterman" <fschwiet at u.washington.edu> wrote in message news:8b9orp$9dj at smc.vnet.net... > I have three lists I want to plot on the same graph, in different colors. > My code went as follows: > (mean and var are lists of numbers, of the same length) > > p1 = ListPlot[ mean, PlotRange->All]; > p2 = ListPlot[ mean + Sqrt[var], > DefaultColor -> RGBColor[0,1,0], PlotRange->All]; > p3 = ListPlot[ mean - Sqrt[var], > DefaultColor -> RGBColor[1,0,0], PlotRange->All]]; > Show[p1,p2,p3]; > > > But this unfortunately draws p1, p2, and p3 on separate plots before drawing > all three on a single plot, and they were all black on the last plot anyhow. > > So I was clever, and came up with the following: > > Show[ > ListPlot[ mean, PlotRange->All], > ListPlot[ mean + Sqrt[var], > DefaultColor -> RGBColor[0,1,0], PlotRange->All], > ListPlot[ mean - Sqrt[var], > DefaultColor -> RGBColor[1,0,0], PlotRange->All]] > > Which produces the same result. ugh. Any advice? > > best karma to the best answers. :) > > > Here is a way built on your example (with fictitious data) mean = Table[Random[], {5}]; var = Table[Random[], {5}]; Show[Block[{$DisplayFunction = Identity}, {ListPlot[mean, PlotStyle -> {PointSize[.02]}, PlotRange -> All], ListPlot[mean + Sqrt[var], PlotStyle -> {RGBColor[0, 1, 0], PointSize[.02]}, PlotRange -> All], ListPlot[mean - Sqrt[var], PlotStyle -> {RGBColor[1, 0, 0], PointSize[.02]}, PlotRange -> All] }]]; The Block temporarilly defines $DisplayFunction; when the construction emerges from block the default value is available for Show. You might also like to look up the standard package Graphics`MultipleListPlot` Allan --------------------- Allan Hayes Mathematica Training and Consulting Leicester UK www.haystack.demon.co.uk hay at haystack.demon.co.uk Voice: +44 (0)116 271 4198 Fax: +44 (0)870 164 0565