Consider the following code
n = 6;
hexagon[x_, y_] :=
Polygon[Table[{x, y} + {Sin[2 Pi j/6], Cos[2 Pi j/6]}, {j, 0, 5}]];
hexagoncenter =
Flatten[Table[{Sqrt[3] i + Sqrt[3]/2 j, 3/2 j}, {j, 0, n - 1}, {i,
0, n - j - 1}], 1];
hexagondist = Norm /@ hexagoncenter;
hexagonlist = hexagon[Sequence @@ #] & /@ hexagoncenter;
hassoc = Association @@ (#[[1, 1]] -> #[[All, 2]] & /@
GatherBy[Transpose[{hexagondist, hexagonlist}], First]);
coloredHexagons =
KeyValueMap[
Function[{key, hexagons}, {ColorData["DarkRainbow"][RandomReal[]],
hexagons}], hassoc];
slice = Graphics[{EdgeForm[{Thick, Transparent}], coloredHexagons}]
When I export it as a PDF file, I get a strange overlapping of the hexagons, as seen in this zoomed picture
Any idea as to why this happens? I suspect it might have to do with how the Edge
is setup, but I am not sure. Any ideas?