RE: how to plot 2 functions in different colors?
- To: mathgroup at smc.vnet.net
- Subject: [mg33605] RE: [mg33583] how to plot 2 functions in different colors?
- From: David.Annetts at csiro.au
- Date: Wed, 3 Apr 2002 01:13:34 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Hi Guojun, > I can plot two functions in one diagram with > plot[{fa[x],fb[x]},{x,1,100}], > but they are in same color and hard to seperated. Is there > any way to make them in different colors? Yes there is. Just supply a list of plot styles, and plot functions are cycled with plot styles. For two functions, you can define:- myStyle = {RGBColor[1, 0, 0], RGBColor[0, 1, 0], RGBColor[0, 0, 1]}; then Plot[{x, 2x, 3x}, {x, 1, 100}, PlotStyle -> myStyle]; Or, with Graphics`Colors` loaded, you can use:- Plot[{Sin[x], Cos[x]}, {x, -Pi, Pi}, PlotStyle -> {Red, Blue}, FrameTicks -> {PiScale, Automatic, None, None}]; IMHO, it's usually easier to define a list of styles and use the list rather than specify individual colours by their names. One way of defining such a list is:- maxNumberOfCurves = 12; lst = Range[maxNumberOfCurves]/(maxNumberOfCurves + 1.) myStyle2 = Hue[#] & /@ lst There are other methods. Regards, Dave. -------------------------------------------------------- Dr. David Annetts EM Modelling Analyst Tel: (+612) 9490 5416 CSIRO DEM, North Ryde Fax: (+612) 9490 5467 David.Annetts at csiro.au Include "usual_disclaimers" --------------------------------------------------------