6
$\begingroup$

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

enter image description here

I need to put it on top the DencityPlot:

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

enter image description here

Using Show doesn't work.

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

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}],
        PlotRangePadding ->
          {{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}]

overlay

$\endgroup$
4
$\begingroup$
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]

enter image description here

$\endgroup$
3
$\begingroup$

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}
    ]
   ]
  }]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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