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
- Follow-Ups:
- Re: Re: Colored ListPlot
- From: Selwyn Hollis <selwynh@earthlink.net>
- Re: Re: Colored ListPlot