[Date Index]
[Thread Index]
[Author Index]
RE: Two questions concerning ListDensityPlot ...
*To*: mathgroup at smc.vnet.net
*Subject*: [mg28512] RE: [mg28497] Two questions concerning ListDensityPlot ...
*From*: "David Park" <djmp at earthlink.net>
*Date*: Tue, 24 Apr 2001 01:48:49 -0400 (EDT)
*Sender*: owner-wri-mathgroup at wolfram.com
Daniel,
My first response was done late at night. Here is something more efficient
and with the kind of tick labels you want.
More efficient color function.
colorfun[max_] = Which[#1 == 0, Hue[0, 0, 1], #1 > 0,
Hue[0.6, 0.808, 1 - 0.6*(#1/max)], True, Hue[0.925, 0.808,
1 + 0.6*(#1/max)]] & ;
Generation of random matrix.
With[{matsize = 50, nonzeros = 300, maxval = 0.5},
mat = Table[0., {matsize}, {matsize}]; Module[{i, j, val},
Do[val = Random[Real, {0, maxval}]; i = Random[Integer, {1, matsize}];
j = Random[Integer, {1, matsize}]; mat[[i,j]] = If[j >= i, val, -val],
{nonzeros}]]]
Plotting of matrix.
With[{max = Max[Max[mat], -Min[mat]], dim1 = Dimensions[mat][[1]],
dim2 = Dimensions[mat][[2]]}, ListDensityPlot[Reverse[mat],
ColorFunction -> colorfun[max], ColorFunctionScaling -> False,
FrameTicks -> {None, Table[{i, dim1 - i}, {i, 0, dim1, 10}],
Table[i, {i, 0, dim2, 10}], None}, Background ->
RGBColor[0.980407, 0.941206, 0.902005],
PlotLabel -> "Sparse Matrix Plot", ImageSize -> 500]];
David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/
> From: Daniel Kattnig [mailto:d.kattnig at chello.at]
To: mathgroup at smc.vnet.net
> Dear Mathematica experts,
>
> I'm actually trying to visualize sparsity patterns of matrixes using
> Mathematica's ListDensityPlot. However, doing so I have uncounted two
> problems ...
>
> 1. Given a (sparse) matrix A, I'm trying to establish a one-to-one
> correspondence between the plot and the matrix it is based on,
> i.e. I want
> the A[[1,1]] element to be plotted at the upper left and
> A[[Dimensions[A][[1]],Dimensions[A][[2]]]] at the lower right
> corner. I've
> realized this by plotting
> Partition[Reverse@Flatten[A],Dimensions[A][[2]]]
> instead of A. However, doing so, I do not succeed in adjusting the labels
> appropriately since setting
> MeshRange->{{0,Dimensions[A][[1]]},{Dimensions[A][[2]],0}} does
> not invert
> the numbering of the ordinate as I've expected. Therefor my question is:
> How can I plot the matrix preserving the one-to-one correspondence and
> adjust the mesh such that the upper left corner corresponds to
> x=1, y=1 and
> the lower right to x=Dimensions[A][[2]], y=Dimensions[A][[1]]?
>
> 2. I'm desperately looking for a color function that allows the
> intermediate values to be kept white, while maxima and minima are colored
> red and blue respectively with the "color intensity" indicating their
> absolute value. Applied to my sparse matrix problem I want the negative
> entries to be blue, the positive to be red whereas the majority
> of entries
> corresponding to zero should remain white. By the way, any suggestions
> concerning the visualization of complex valued entries are also highly
> appreciated. Is there an easy way to keep the phase information?
>
> Sincerely,
> Kattnig
> two questions concerning ListDensityPlot
>
>
Prev by Date:
**Re: Algebraic Integers**
Next by Date:
**RE: Two questions concerning ListDensityPlot ...**
Previous by thread:
**Re: Two questions concerning ListDensityPlot ...**
Next by thread:
**RE: Two questions concerning ListDensityPlot ...**
| |