# Want to overlay a density plot with a grid of graphics

I have a GraphicsGrid object:

mycircle =
GraphicsGroup[
{Circle[], Arrowheads[.2], Arrow[{{0, 1}, {0.1, 1}}],
White, Circle[{0, 0}, 1.2]}];

circles =
GraphicsGrid @
Table[Graphics[
GeometricTransformation[
mycircle,
ShearingTransform[RandomReal[-1, 1][[1]], {1, 0}, {0, 1}]]],
{10}, {10}]


That produces the grid

I need to put it on top the DencityPlot:

DensityPlot[x^2 + y^2, {x, -10, 10}, {y, -10, 10}]


Using Show doesn't work.

• The coordinates of circles are nowhere near the coordinate range of your DensityPlot, which is why Show seems to fail. – Michael E2 Feb 26 '18 at 0:19

It can be done with GraphicsGrid and Overlay, but you get visual centering of the distorted circles rather than precise centering at specific lattice points.

mycircle =
GraphicsGroup[
{Circle[], Arrowheads[.2], Arrow[{{0, 1}, {0.1, 1}}],
White, Circle[{0, 0}, 1.2]}];

SeedRandom[42];
circles =
GraphicsGrid[
Table[
Graphics[
GeometricTransformation[
mycircle,
ShearingTransform[RandomReal[-1, 1][[1]], {1, 0}, {0, 1}]]], {10}, {10}],
{{Scaled[.12], Scaled[.07]}, {Scaled[.11], Scaled[.07]}},
ImageSize -> {400, 400}];

plot = DensityPlot[x^2 + y^2, {x, -10, 10}, {y, -10, 10}, ImageSize -> {400, 400}];

Overlay[{plot, circles}]


mycircle = GraphicsGroup[{Circle[], Arrowheads[.03], Arrow[{{0, 1}, {0.1, 1}}],
White, Circle[{0, 0}, 1.2]}];

circles2 = Graphics[Table[GeometricTransformation[mycircle,
Composition[AffineTransform[{{{1/2, 0}, {0, 1/2}}, {i, j}}],
ShearingTransform[RandomReal[-1, 1][[1]], {1, 0}, {0, 1}]]],
{i, -9, 9, 2}, {j, -9, 9, 2}]];

Show[DensityPlot[x^2 + y^2, {x, -10, 10}, {y, -10, 10}], circles2]


One way is to use Inset and specify the position of the circles by hand:

mycircle =
GraphicsGroup[{Circle[], Arrowheads[.2], Arrow[{{0, 1}, {0.1, 1}}],
White, Circle[{0, 0}, 1.2]}];
circles0 =
Table[Graphics[
GeometricTransformation[mycircle,
ShearingTransform[
RandomReal[-1, 1][[1]], {1, 0}, {0, 1}]]], {10}, {10}];
background = DensityPlot[x^2 + y^2, {x, -10, 10}, {y, -10, 10}];
Show[{
background,
Graphics[
MapIndexed[
{g, idx} \[Function] Inset[g, 2 idx - 11, {0, 0}, {1, 1}],
circles0,
{2}
]
]
}]