MathGroup Archive 2007

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

Search the Archive

Re: listdensityplot, black box?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg74846] Re: listdensityplot, black box?
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Sun, 8 Apr 2007 05:03:15 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <ev7j5d$l36$1@smc.vnet.net>

alexxx.magni at gmail.com wrote:
> I have a rectangular grid of data (249x400) in the simple form of
> values 0/1, e.g:
> {{1, 1, 0, ......, 1, 1, 1, 0, 0, 0, 0}, ... }
> 
> I read them with
> 
> - lab=Import["...image.pbm"]
> 
> - lab2 = lab[[1, 1]]
> 
> and Show[Graphics[Raster[lab2]]] shows the image OK.
> 
> Now, whenever I do:
> 
> - ListDensityPlot[lab2]
> 
> I get no errors, but a completely black plot - of the correct size
> 249x400, however.
> 
> I played a little with ColorFunction and ColorOutput, but it didnt
> help.
> 
> Do you have any idea what I'm doing wrong???
> 
> thanks for any help...
> 
> 
> Alessandro Magni

Hi Alessandro,

What you did is fine. However, the default size of the DensityGraphic 
object, generated by ListDensityPlot, is too small to render correctly 
(that is to make discernible) the mesh and the tiny black and white 
squares. To solve the issue, just increase the size of the image to some 
large enough still convenient values.

In[1]:=
(* Generate a random array of binary values *)
lab2 = Table[Random[Integer], {249}, {400}];

(* This is an alternative to Show[Graphics[...]] *)
ArrayPlot[lab2]

(* Adding a mesh, the plot becomes a gray rectangle *)
ArrayPlot[lab2, Mesh -> True]

(* Default size shows a black rectangle *)
ListDensityPlot[lab2]

(* With this setting, one can clearly see the grid of black and white 
squares *)
ListDensityPlot[lab2, ImageSize -> 4*Dimensions[lab2]]


Regards,
Jean-Marc


  • Prev by Date: .NET/Link Callback from a DLL
  • Next by Date: Re: Fractals and Time Series Analysis by R.J. Korsan appearing in
  • Previous by thread: Re: listdensityplot, black box?
  • Next by thread: Re: listdensityplot, black box?