# Question:Can Maple represent 2D density plots?

## Question:Can Maple represent 2D density plots?

Maple

Suppose you do this

```restart:
with(plots):
with(Statistics):
A := Sample(RandomVariable(Normal(0, 1)), 10^4):
B := Sample(RandomVariable(Normal(0, 1)), 10^4):
ScatterPlot(A, B, symbol=point);
```

The plot shows a greater density of dots around (0, 0) and they become increasingly sparse as one moves away from (0, 0).
A pretty way to represent such clouds is to do "2D density plots".
You will find some example from R here  2d-density-plot-with-ggplot2.html

For the moment I do something like this (which is to be adpated for almost any particular case).
My main question is: do recent versions of MAPLE possess something similar to R's features?

 > restart:
 > interface(version);
 (1)
 > with(Statistics):
 > UseHardwareFloats := false: N := 10^5: A := Sample(RandomVariable(BetaDistribution(2, 6)), N): B := Sample(RandomVariable(BetaDistribution(6, 2)), N): nb := 50: mA := min(A): hA := Range(A)/(nb-1): mB := min(B): hB := Range(B)/(nb-1): cA := floor~((A-~mA)/~hA)+~1: cB := floor~((B-~mB)/~hB)+~1: NP := Matrix(nb\$2, 0): for n from 1 to N do   NP[cA[n], cB[n]] := NP[cA[n], cB[n]]+1 end do: NP:
 > plots:-matrixplot(   NP,   heights=histogram,   colorscheme=["Blue", "White", "Red"],   orientation=[270, 0, 0],   style=patchnogrid,   lightmodel=none,   labels=["A", "B", ""],   axis[1]=[tickmarks=[nb+1=max(B), 1=mB]],   axis[2]=[tickmarks=[nb+1=max(A), 1=mA]] )
 >