def draw_punchcard(infos, ax1=list(range(7)), ax2=list(range(24)), ax1_ticks=['Monday',
    'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'],
    ax2_ticks=list(range(24)), ax1_label='Day', ax2_label='Hour'):
    data = np.zeros((len(ax1), len(ax2)))
for key in infos:
    data[key[0], key[1]] = infos[key]
data = data / float(np.max(data))
r = float(data.shape[1]) / data.shape[0]
for y in range(data.shape[0]):
    for x in range(data.shape[1]):
        circle = plt.Circle((x / float(data.shape[1]) * data.shape[0], y /
            r), data[y][x] / float(data.shape[1]) * data.shape[0] / 2)
plt.gca().add_artist(circle)
plt.ylim(0 - 0.5, data.shape[0] - 0.5)
plt.xlim(0, data.shape[0])
plt.yticks(np.arange(0, len(ax1) / r - 0.1, 1 / r), ax1_ticks)
plt.xticks(np.linspace(0, len(ax1), len(ax2)) + 0.5 / float(data.shape[1]),
    ax2_ticks)
plt.xlabel(ax1_label)
plt.ylabel(ax2_label)
plt.gca().invert_yaxis()
plt.axis('equal')
plt.axis([0, 7.02, 7 / r, -0.5])
scale = 0.5
plt.gcf().set_size_inches(data.shape[1] * scale, data.shape[0] * scale,
    forward=True)
Matplotlib: как убрать вертикальное пространство при отображении кругов на сетке?