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: [mg73374] Re: conditional plotstyles in ListPlot
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Wed, 14 Feb 2007 05:23:07 -0500 (EST)
  • Organization: The Open University, Milton Keynes, UK
  • References: <eqs9am$ik5$1@smc.vnet.net>

Stern 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.

Hi Michael,

Splitting your graph in two is not required. In the following example,
we use a pure function to build a sequence of pairs {color, point}.

In[1]:=
data = Sort[Table[Random[Integer, {-5, 5}], {10}, {2}]];
ListPlot[data, PlotJoined -> True,
    Epilog -> {AbsolutePointSize[4],
      ({If[#1[[2]] > 0, Red, Green], Point[#1]} & ) /@ data}];

Hope this helps,
Jean-Marc


  • Prev by Date: Re: conditional plotstyles in ListPlot
  • Next by Date: Re: Curve-fitting/data analysis question...
  • Previous by thread: Re: conditional plotstyles in ListPlot
  • Next by thread: Re: conditional plotstyles in ListPlot