MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: PlotStyles

  • To: mathgroup at smc.vnet.net
  • Subject: [mg30902] Re: [mg30858] Re: [mg30815] PlotStyles
  • From: BobHanlon at aol.com
  • Date: Sun, 23 Sep 2001 02:16:48 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

In a message dated 2001/9/20 4:36:45 AM, BobHanlon at aol.com writes:

>In a message dated 2001/9/19 12:47:47 AM, mcoleman at bondspace.com writes:
>
>>Is there a way to apply different PlotStyles to a single list of data
>
>>in a List Plot command? For instance, can I specifiy the first
>>half of the data points to be one color, and the remaining half to be
>>another, so that it is easy to visually separate the two subsets of data.
>>
>>I know that this could be done by creating separate graphs and then 
>>overlaying them,  but I'm curious is this can be done within a single
>
>>Plot or ListPlot command.
>>
>
>You can use a single MultipleListPlot by partitioning the data
>
>Needs["Graphics`Colors`"];
>Needs["Graphics`MultipleListPlot`"];
>Needs["Graphics`Graphics`"];
>
>data = Table[{x, Exp[-Sqrt[x]]*Sin[2x]}, 
>      {x, 0, 3Pi, Pi/16}];
>
>MultipleListPlot[n=0; 
>    (Take[data, (-1)^n++ * #[(Length[data]+1)/2]])& /@  
>      {Floor, Ceiling}, PlotJoined->True,
>    Frame->True, Axes->False, PlotRange->All,
>    FrameTicks->{PiScale, Automatic, None, None},
>    SymbolShape->None,
>    PlotStyle->{{AbsoluteDashing[{5,5}], Blue}, Red}];
>

This can automatically partition the data into two or more segments

Needs["Graphics`Colors`"];
Needs["Graphics`MultipleListPlot`"];

ListPlotSplit[data_List, m_Integer, opts___] := 
    Module[{n = Length[data], p}, 
      p = Table[Floor[n/m], {m}] + 
          PadLeft[Table[1, {Mod[n,m]}], m]; 
      MultipleListPlot[Take[data, #]& /@ (Rest[
                FoldList[({0, #2} + #1[[2]])&, {0,1}, p]] /. 
              (n+1) :> n), opts, 
        PlotStyle -> {Red, Blue}]];

data = Table[{x, Exp[-Sqrt[x]]*Sin[2x]}, 
      {x, 0, 4Pi, Pi/16}];

The default will alternate between Red and Blue

ListPlotSplit[data, 4, PlotJoined -> True, 
    PlotRange -> All, SymbolShape -> None, 
    ImageSize -> 400, Frame -> True, Axes -> False];

This can be overridden

ListPlotSplit[data, 4, PlotJoined -> True, 
    PlotRange -> All, SymbolShape -> None, 
    ImageSize -> 400, Frame -> True, Axes -> False, 
    PlotStyle -> {DarkGreen, Red, Gold, Blue}];


Bob Hanlon
Chantilly, VA  USA


  • Prev by Date: Mathematica notebook saving bug ?
  • Next by Date: Re: Some advanced formatting options.
  • Previous by thread: RE: PlotStyles
  • Next by thread: Importing File and 3D Graphics