Re: Labelled matrix plot
- To: mathgroup at smc.vnet.net
- Subject: [mg81071] Re: Labelled matrix plot
- From: m.r at inbox.ru
- Date: Mon, 10 Sep 2007 18:55:50 -0400 (EDT)
- References: <fbogau$eg0$1@smc.vnet.net>
On Sep 6, 4:13 am, Yaroslav Bulatov <yarosla... at gmail.com> wrote: > I'd like to do a matrix plot of a 72x72 matrix with columns/rows > labelled. > I implemented it by making 72^2 rectangles and arranging them in a > Grid, and after some tweaking of Spacings/ItemSize it looks just right > on screen, but I can't figure out how to save the result in an image. > > 1. The expression is too big to fit on screen so "Right Click/Copy As" > only copies part of it > 2. Exporting the Grid as a PNG file cuts off the part not showing on > the screen > 3. Graphics[Inset[grid]] changes the color, spacing, and leaves out > non-graphical label elements > 4. Saving as HTML file cuts off the file before the grid > > Am I running into some built-in limitations of Grid? And if so, what > is the recommended way of implementing > a labelled matrix plot? (this is in Mathematica 6.0.1) > > http://www.yaroslavvb.com/research/ideas/hmms/real-matrices/labelled-...http://www.yaroslavvb.com/research/ideas/hmms/real-matrices/labelled-... You can try using ArrayPlot with custom tick marks: vals = Union @@ bigramCountsMatrix; ticks = Thread@ {Range@ Length@ ordmap, ordmap[[All, 1]], 0}; cdf = Interpolation[ MapIndexed[{#, (#2[[1]] - 1)/(Length@ vals - 1)}&, vals], InterpolationOrder -> 1]; gr = ArrayPlot[bigramCountsMatrix, FrameTicks -> {{ticks, None}, {None, ticks}}, PlotRangePadding -> 0, ColorFunction -> (GrayLevel[1 - Sqrt@ cdf@ #]&), ColorFunctionScaling -> False] Export["/1.png", gr, ImageSize -> {Automatic, 768}] Also note that your graphics weren't aligning properly because of ImagePadding and PlotRangePadding: Grid[{{Graphics[{Red, Rectangle[]}, ImagePadding -> 0, PlotRangePadding -> 0], Graphics[{Green, Rectangle[]}, ImagePadding -> 0, PlotRangePadding -> 0]}}, Spacings -> 0] Maxim Rytin m.r at inbox.ru