Re: How to convert a matrix into a graph?
- To: mathgroup at smc.vnet.net
- Subject: [mg37833] Re: [mg37765] How to convert a matrix into a graph?
- From: Rolf Mertig <rolf at mertig.com>
- Date: Thu, 14 Nov 2002 06:12:06 -0500 (EST)
- Organization: Mertig Consulting
- Reply-to: rolf at mertig.com
- Sender: owner-wri-mathgroup at wolfram.com
Hi, one possibility is: Options[PlotMat] = {ColorFunction -> (GrayLevel[1 - #1] & ), PointSize -> 0.01, ShowOptions -> {AspectRatio->1,Axes -> False, ImageSize -> 500, PlotRange -> All, AxesOrigin -> {0, 0}}}; PlotMat[m_?MatrixQ, opts___?OptionQ] := Module[ {op = Join[Flatten[{opts}],Options[PlotMat]]/. {a___,ShowOptions->s1_List,b___,c___,ShowOptions->s2_List,d___}:> {a,ShowOptions->Join[s1,s2],b,c,d}, maxnum = Max[m]}, o=op; Show[Graphics[MapIndexed[{(ColorFunction /. op)[#1/maxnum], PointSize[PointSize /. op], Point[#2]} & , m, {-1}]], ShowOptions /. op]]; PlotMat[Table[Random[], {100}, {100}]]; (* using Hue as coloring function looks also nice: *) PlotMat[Table[Random[], {100}, {100}], ColorFunction -> Hue,ShowOptions->{Frame->True,Axes->True}]; (* ************************** *) Rolf -- Rolf Mertig Mertig Consulting Specialized Software & Training http://www.mertig.com