3
$\begingroup$

I was wondering if there is any way to highlight the values in ArrayPlot in the same way that it is possible for DensityHistogram. Something along the lines of the plot below but in cases where I already have the array.

data = RandomReal[NormalDistribution[0, 1], {100, 2}];
DensityHistogram[data, PerformanceGoal -> "Quality"]

enter image description here

$\endgroup$

1 Answer 1

3
$\begingroup$
m = Partition[Range @ 20, 5];

ArrayPlot[m, Mesh -> All, 
 Epilog -> MapIndexed[Tooltip[{Opacity[0], Rectangle[#2 - 1]}, Style[#, 16]]&,
   Transpose @ Reverse @ m, {2}]]

enter image description here

$\endgroup$
2
  • $\begingroup$ thanks! while this work it is actually not aligned well: ``` ArrayPlot[m, Mesh -> All, Epilog -> MapIndexed[ Tooltip[{Opacity[.5], Rectangle[#2 - 1/2]}, Style[#, 16]] &, Transpose@Reverse@m, {2}]] ``` reveals this. $\endgroup$
    – elbOlita
    Commented Feb 16 at 14:57
  • $\begingroup$ Thank you @elbOlita; fixed the alignment issue. $\endgroup$
    – kglr
    Commented Feb 16 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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