Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

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

Search the Archive

Re: conditional plotstyles in ListPlot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg73373] Re: [mg73342] conditional plotstyles in ListPlot
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Wed, 14 Feb 2007 05:22:35 -0500 (EST)
  • Reply-to: hanlonr at cox.net

Needs["Graphics`"];

data=Table[{t,20*Random[]-10},{t,20}];

DisplayTogether[
    ListPlot[Select[data,#[[2]]>=0&],
      PlotStyle->{AbsolutePointSize[4],Blue}],
    ListPlot[Select[data,#[[2]]<0&],
      PlotStyle->{AbsolutePointSize[4],Red}]];

DisplayTogether[
    ListPlot[data,PlotJoined->True,
      PlotStyle->{GrayLevel[.5],AbsoluteDashing[{5,5}]}],
    ListPlot[#,PlotStyle->{AbsoluteThickness[2],
              Hue[.35(Sign[#[[-1,2]]]+1)]},
          PlotJoined->True]&/@
      Split[data,Sign[#1[[2]]]==Sign[#2[[2]]]&]];

DisplayTogether[
    ListPlot[data,PlotJoined->True,
      PlotStyle->{GrayLevel[.5],AbsoluteDashing[{5,5}]}],
    ListPlot[#,PlotStyle->{AbsoluteThickness[2],
              Hue[.35(Sign[#[[-1,2]]]+1)]},
          PlotJoined->True]&/@
      Split[data,Sign[#1[[2]]]==Sign[#2[[2]]]&],
    ListPlot[Select[data,#[[2]]>=0&],
      PlotStyle->{AbsolutePointSize[4],Blue}],
    ListPlot[Select[data,#[[2]]<0&],
      PlotStyle->{AbsolutePointSize[4],Red}]];


Bob Hanlon

---- Stern <nycstern at gmail.com> wrote: 
> I am plotting a time series and would like to use different colors for
> points above the x-axis from the colors below the x-axis. I can think
> of some relatively inelegant ways of doing this, splitting my dataset
> in two, plotting them separately, and them showing the graphs
> together, but I feel as though there may be a better solution.
> 
> Help?
> 
> Thank you,
> 
> Michael
> 



  • Prev by Date: Re: numerical_solution
  • Next by Date: Re: conditional plotstyles in ListPlot [additional note]
  • Previous by thread: Re: conditional plotstyles in ListPlot
  • Next by thread: MathPlayerSetup installation