# How do I make a frequency heatmap?

I have an array of data that has repeats in it. I want to generate a heatmap depending on how much repetition each point has, as in how many times it is repeated.

-
... and what have you tried? – belisarius Jan 9 at 20:05
It would have helped if you specified in what way you want to represent the various counts, e.g., as different colors, or as different intensities of a single color (possibly gray), and with what resolution, i.e., separation of points. – murray Jan 9 at 20:10
I would like it to be smooth and preferably red for high frequency and blue for low frequency. – alfonzo1955 Jan 9 at 23:22
possible duplicate of How to create a heatmap from list of coordinates? – Jens Jan 10 at 3:38
@SjoerdC.deVries My opinion is that the question isn't specific enough to rule out that it's a duplicate, so without evidence to the contrary it's not useful to keep it open unless people want to do telepathy to answer this. – Jens Jan 10 at 18:51
show 1 more comment

Tally is good help in this case, it counts the number of occurances. Using this it's easy to construct a replacement rule that replaces each element with the number of occurances, which you can then plot.

bd = BinomialDistribution[10, 0.4];
m = RandomVariate[bd, {100, 100}];
counts = Tally[Flatten[m]]
rule = Rule @@@ counts
ArrayPlot[m /. rule, ColorFunction -> "Rainbow"]


-
 Tally and ListDensityPlot is what I needed. Thanks! – alfonzo1955 Jan 10 at 22:57
ArrayPlot[# /. Rule @@@ Tally@Flatten@#] &@RandomInteger[10, {20, 20}]


Edit

Smoothing:

data = RandomInteger[{0, 10}, {20, 20}];
f = Interpolation@Flatten[MapIndexed[{Sequence @@ #2, #1} &, # /.
Rule @@@ Tally@Flatten@# &@ data, {2}], 1];
DensityPlot[f[x, y], {x, 1, 20}, {y, 1, 20}, ColorFunction -> ColorData["TemperatureMap"]]


-
 data = RandomInteger[10, {200, 2}];
DensityHistogram[data, 11, "Count",
Method -> {"DistributionAxes" -> "BoxWhisker"},
ColorFunction -> "Rainbow",
FrameTicks -> {Thread[{Range[0.5, 10.5, 1.], ToString /@ Range[0, 10, 1]}],
Thread[{Range[0.5, 10.5, 1.], ToString /@ Range[0, 10, 1]}]}]


-