Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The DensityHistogram command lets you specify a ChartElementFunction which according to the documentation:

The arguments supplied to ChartElementFunction are the bin region {{xmin,xmax},{ymin,ymax}}, the bin values lists, and metadata {m1,m2,...}.

My question is how can I use the bin values lists and the metadata? When I try to access them all I get something like

share|improve this question
I think you're out of luck for the time being. – Brett Champion Oct 23 '12 at 16:36
up vote 2 down vote accepted

It doesn't look like the last two parameter sets that the documentation promises are passed to ChartElementFunction are actually passed. A test:

DensityHistogram[RandomVariate[BinormalDistribution[.5], 20], 
   ChartElementFunction -> Print];












The bin lists themselves can be obtained in two ways:

Firstly, from the internals of DensityHistogram using the height specification function (one possibility for the third argument):

data = RandomVariate[BinormalDistribution[.5], 20];

  DensityHistogram[data, Automatic, ((Sow[{##}, bindata]; ##) &)], 

Mathematica graphics

Secondly, using HistogramList:


{{{-2, -1, 0, 1, 2, 3}, {-2, -1, 0, 1, 2}}, {{0, 2, 1, 0}, {1, 0, 3, 0}, {0, 3, 3, 0}, {0, 0, 2, 4}, {0, 0, 1, 0}}}

As you can see, the bin boundary specification is written slightly different, but is in principle the same. The bin count lists are the same.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.