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