Re: newby plotting question
- To: mathgroup at smc.vnet.net
- Subject: [mg22751] Re: newby plotting question
- From: "Seth Chandler" <SChandler at uh.edu>
- Date: Fri, 24 Mar 2000 03:27:49 -0500 (EST)
- Organization: University of Houston
- References: <8b9orp$9dj@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
The key here is to realize that functions such as ListPlot produce a Mathematica expression which has Graphics as its head, who first argument is a list of Graphics primitives and which then has lots of optional arguments that take the form of Rule expressions. You can see this by, for example, asking the kernel to evaluate InputForm[p2] or Shallow[InputForm[p2]]. The DefaultColor argument you have provided to the ListPlot expression creates a rule that is used by the DisplayFunction to display the points in question, but that does not itself alter those points. To see this, type the following: p2revised=ListPlot[mean + Sqrt[var],PlotRange->All,PlotStyle->RGBColor[0,1,0]]. To the naked eye, the result looks the same, but in fact it is not. Type InputForm[p2revised]. You will now see a graphics primitive RGBColor[0,1,0] prepended to your list of graphics primitives. Thus, if you now type Show[p1,p2revised,p3] the green color of the p2revised graphic is preserved, whereas the colors of p1 and p3 are not preserved. As to your second observation that you keep getting unnecessary plots of all the lists rather than one combined plot, the key is to know about the option DisplayFunction->Identity (which supresses the picture) and DisplayFunction->$DisplayFunction (which creates the standard picture). Thus, I believe the following will give you what you want. p1revised = ListPlot[ mean, DisplayFunction -> Identity, PlotStyle -> RGBColor[0, 0, 0]]; p2revised = ListPlot[ mean + Sqrt[var], DisplayFunction -> Identity, PlotStyle -> RGBColor[0, 1, 0]]; p3revised = ListPlot[mean - Sqrt[var], DisplayFunction -> Identity, PlotStyle -> RGBColor[1, 0, 0]]; Show[p1revised, p2revised, p3revised, DisplayFunction -> $DisplayFunction, PlotRange -> All] Seth J. Chandler Assoc. Prof. of Law Univ. of Houston Law Center If you "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. :) > > >