Re: newby plotting question
- To: mathgroup at smc.vnet.net
- Subject: [mg22756] Re: [mg22711] newby plotting question
- From: "Tomas Garza" <tgarza at mail.internet.com.mx>
- Date: Fri, 24 Mar 2000 03:28:00 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
F. Schwieterman wrote: > 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? Cf. the Help Browser under Show:"When plots are combined, their lists of non-default options are concatenated." You are combining plots p1, p2, p3 and hence the non-default options are concatenated. This means that you are in effect concatenating DefaultColor -> RGBColor[0,1,0] and DefaultColor -> RGBColor[1,0,0]. Hence you have a conflict, and Show reconciles this problem by using the options of the first object (see Wickham-Jones book on Mathematica Graphics, p.232), in your example p1. Try Show[p2,p1,p3] and you'll see a different color for the combined graph. But I guess you only want to apply colors to the points, not to the axes and the rest of the plot. Then I suggest you use PlotStyle instead of DefaultColor. This will do the trick. BTW, if you only want to display the combined graph, use the option DisplayFunction->Identity in each of p1, p2 and p3, and then DisplayFunction->$DisplayFunction in Show. This saves a lot of space in your notebook. Tomas Garza Mexico City