MathGroup Archive 2001

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

Search the Archive

RE: PlotStyles

  • To: mathgroup at smc.vnet.net
  • Subject: [mg30838] RE: [mg30815] PlotStyles
  • From: "David Park" <djmp at earthlink.net>
  • Date: Thu, 20 Sep 2001 03:51:33 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Mark,

Here is a sample list of data points for plotting.

pts = Table[{x, Sin[x]}, {x, 0, 2Pi, 2Pi/50}];

Let's say that we want to plot the first half of the curve in blue and the
second half in red. We have to break our list of points into two lists, with
the break point repeated. There are several ways this could be done.

pts1 = Take[pts, {1, 26}];
pts2 = Take[pts, {26, 51}];

pts1 = Cases[pts, {x_ /; 0 <= x <= Pi, _}];
pts2 = Cases[pts, {x_ /; Pi <= x <= 2Pi, _}];

pts1 = Select[pts, 0 <= #1[[1]] <= Pi & ];
pts2 = Select[pts, Pi <= #1[[1]] <= 2*Pi & ];

Then forget ListPlot. It is easier to do it this way.

Needs["Graphics`Colors`"]
Show[Graphics[
      {Blue, Line[pts1],
       Red, Line[pts2]}],
    Frame -> True];

If you also want to plot the points:

Show[Graphics[
      {Blue, Line[pts1],
       Red, Line[pts2],
       Black, AbsolutePointSize[3], Point /@ pts}],
    Frame -> True];


David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/



> From: Mark S. Coleman [mailto:mcoleman at bondspace.com]
To: mathgroup at smc.vnet.net
>
> Greetings
>
>
> 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.
>
> Thanks,
>
> Mark
>



  • Prev by Date: RE: Sum of Prime factors
  • Next by Date: RE: NIntegrate Precision
  • Previous by thread: Re: PlotStyles
  • Next by thread: RE: PlotStyles