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

MathGroup Archive 2002

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

Search the Archive

Re: Colored ListPlot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg36904] Re: Colored ListPlot
  • From: Selwyn Hollis <slhollis at earthlink.net>
  • Date: Tue, 1 Oct 2002 04:45:54 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Here's a refinement of my previous post. Everything is wrapped up in a 
function named DotPlot, which takes the following options:

ColorFunction (default: Hue)
ColorFunctionScaling (default: True)
DotSize (default: 0.01)

You can also provide other options such as Axes, Frame, Background, etc.


   Needs["Utilities`FilterOptions`"];

   DotPlot[data_?MatrixQ, opts___Rule] :=
    Module[{colorfn, scale, dotsize},
     colorfn = ColorFunction/.{opts}/.{ColorFunction->Hue};
     scale = ColorFunctionScaling/.{opts}/.{ColorFunctionScaling->True};
     dotsize = DotSize/.{opts}/.{DotSize->.01};
     With[{m = If[scale,{Min[#],Max[#]}&@Transpose[data][[3]], {0,1}]},
       Show[(Graphics[
       {colorfn[#[[3]]],PointSize[dotsize],Point[{#[[1]],#[[2]]}]}]&)/@
           (data /. {x_,y_,z_}-> {x,y,(z-m[[1]])/(m[[2]]-m[[1]])}),
           FilterOptions[Graphics, opts]
           ] ] ]


Example:

   vals = Table[{Random[], Random[], .5 Random[]}, {100}];

   DotPlot[vals, ColorFunction -> (Hue[#, 1, 1-#] & ),
     ColorFunctionScaling -> False, DotSize -> 0.02, Frame -> True]


---
Selwyn Hollis



  • Prev by Date: Re: How to get a listing of currently defined symbols
  • Next by Date: Re: Re: Are configuration & UI better in 4.2?
  • Previous by thread: Re: Colored ListPlot
  • Next by thread: Re: Re: Colored ListPlot