Re: newby plotting question
- To: mathgroup at smc.vnet.net
- Subject: [mg22725] Re: newby plotting question
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Fri, 24 Mar 2000 03:27:08 -0500 (EST)
- Organization: Universitaet Leipzig
- References: <8b9orp$9dj@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
I make some data
data = Table[{t, t^2, 0.5}, {t, 0, 4, 1/32}];
Split the data
{tt, mean, var} = Transpose[data];
and make the plots
Block[{$DisplayFunction = Identity},
p1 = ListPlot[Transpose[{tt, mean}], PlotStyle -> RGBColor[0, 0, 0]];
p2 = ListPlot[Transpose[{tt, mean + var}], PlotStyle -> RGBColor[1, 0,
0]];
p3 = ListPlot[Transpose[{tt, mean - var}], PlotStyle -> RGBColor[0, 1,
0]];
]
now lets show all together
Show[p1, p2, p3]
Now the explanation: To prevent the display of the plot you must set
DisplayFunction->Identity, since you do it three times it's better to
set display function inside a Block[] to Identity.
Since DefaultColor is a Graphics[] option Show[] will use the option set
from it's
first argument to display all three plots. So your Default color for the
last
two plots gets lost. But we can put the color directive into the
graphics data
by seting PlotStyle and get something like {RGBColor[1,0,0],Line[_]} in
the
graphics. If the plots are now combined the color is preserved and all
works
as expected.
Hope that helps
Jens
"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?
>
> best karma to the best answers. :)