MathGroup Archive 1998

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

Search the Archive

Re: ListPlot + Colors



Fermat wrote:
> 
> I'm using Mathematica 3.01.
> I have ListPlot[{{1,2},{1,3},{2,2}}] and want to display the 3 points in
> 2 different colors, depending on the first coordinate. The problem
> extends to several thousands upto an infinity of points, so a
> ColorFunction seems appropriate.
> How to do that?
> 
> marinus.heuvel@pi.net


I have been meaning to write a function to do just that, but have not
found the time.  In the mean time, only 3-D graphics have the
ColorFunction option.  If you want to plot points with control over the
colors you will have to do it with primitives.  Start with the FullForm
of your graphics expression and you will see its format in terms of
graphics primitives:

FullForm[ ListPlot[{{1,2},{1,3},{2,2}}]]

returns, in part:

Graphics[List[Point[List[1,2]],Point[List[1,3]],Point[List[2,2]]],
  
    blah, blah,blah]

Every expression Point[List[x,y]] needs to be replaced with an
expression  List[colordirective,Point[List[x,y]]]  which can be a
RGBColor, Hue, etc.  I think this can be most efficiently done with a
MapThread construct.
-- 
Remove the _nospam_ in the return address to respond.



  • Prev by Date: Re: Sqrt Problems
  • Next by Date: Re: MathLink
  • Prev by thread: ListPlot + Colors
  • Next by thread: key entry problems