I found a nice graphic that I want to recreate as a 5-gon using Tikz (the colors are meaningless as well as the white boxes):


In theory I know how to generate this: Filldraw closed graphs using coordinates. But is there a smarter way to get a graphic like this without special packages? Can tikz draw 5-gons equally distant itself given certain commands?

  • see regular polygons, pp 698 (pgf and tikz manual, v 3.0.1a). – Zarko Nov 6 '17 at 11:36

There will be several different ways of doing this, here is one approach.

output of code

   regular polygon,
   regular polygon sides=6,
   minimum size=2cm,
   regular polygon sides=5
\node [hex] (inner) {};
\foreach \i in {1,...,6}
   \path (inner.center) ++({360/6*(\i-0.5)}:2cm) node[hex,fill=blue!10]{};

\node [pent] (inner) at (6,0) {};
\foreach \i in {1,...,5}
   \path (inner.center) ++({90+360/5*(\i-0.5)}:2cm)
      node[pent,fill=blue!10, rotate={360/5*(\i-0.5)}]{};

As a follow-up to Sigur's comments, a small variation where the distance from the center polygon to the surrounding ones are the same in both cases.

\node [hex] (inner) {};
\foreach [evaluate={\j=360/6*(\i-0.5)}] \i in {1,...,6}
   \path (inner.\j) ++(\j:2mm) node[hex,fill=blue!10,rotate=\j-90,anchor=270]{};

\node [pent] (inner2) at (6,0) {};
\foreach [evaluate={\j=90+360/5*(\i-0.5)}] \i in {1,...,5}
   \path (inner2.\j) ++(\j:2mm)
       node [pent,fill=blue!10,rotate=\j-90,anchor=270] {};
  • Nice and pretty. Just observation: the space between the green and blue shapes looks different for hex and pent. But I guess that you used 2cm in both. – Sigur Nov 6 '17 at 13:19
  • I suspect that it is right, only an illusion since the green bottom edges are not aligned. – Sigur Nov 6 '17 at 13:20
  • 2
    @Sigur Not an illusion, they are different. The minium size relates to the diameter of the circumscribed circle I think, so the distance from center to vertex is the same for both polygons. But the hexagon is a better approximation of a circle, so the distance from the center to the middle of one the sides is different -- longer for hexagons. While the distance between the centers of the polygons are the same, the separation is larger because of that effect. – Torbjørn T. Nov 6 '17 at 13:42
  • Very very nice... Maybe I need some coffee to improve my vision... lol – Sigur Nov 6 '17 at 15:23

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.