# Generated by pandoc-plot 1.5.4
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(2019)

"""
Create top banner
"""
import math
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
import itertools

# Hexagon radius in mm
RADIUS = 4

# Dimensions of the bounding box of the hexagons
WIDTH = math.sqrt(3) * RADIUS
HEIGHT = 2 * RADIUS

mm_to_in = 0.03937008

def draw_hexagon(ax, center, radius, color='w'):
    # because the dimensions of the axes have been set in mm,
    # the dimensions of thie hexagon are given in mm as well.
    ax.add_patch(
        mpatches.RegularPolygon(
            xy=center,
            numVertices=6,
            radius=radius,
            facecolor=color,
            edgecolor="k",
            orientation=0,
            fill=True,
        )
    )

figure, ax = plt.subplots(
    1, 1, figsize=(100 * mm_to_in, 100 * mm_to_in), frameon=False
)

# Dimensions of the page in mm
ax.set_xlim([0, 100])
ax.set_ylim([0, 100])

centers=list()
for offset_x, offset_y in [(0, 0), (WIDTH / 2, (3 / 2) * RADIUS)]:
    rows = np.arange(start=offset_x, stop=105, step=WIDTH)
    columns = np.arange(start=offset_y, stop=105, step=3 * RADIUS)
    for x, y in itertools.product(rows, columns):
        centers.append((x,y))

for (x,y) in centers:
    draw_hexagon(ax, center=(x, y), radius=RADIUS)

ax.axis("off")
plt.subplots_adjust(top=1, bottom=0, left=0, right=1)
Click here to see how this plot was generated.