#!/usr/bin/env python3

from sys import argv
from pathlib import Path
import numpy as np
import matplotlib.pyplot as plt

np.random.seed(0)
data = np.random.binomial(n=100, p=1/6, size=1000) * 2

d = np.min(np.diff(np.unique(data)))
min, max = data.min(), data.max()
bins  = np.arange(min-d*(0.5), max+d*(1+0.5), d)
ticks = np.arange(min,         max+d*(1    ), d)
lims  =          [min-d*(0.5), max+d*(0+0.5)]

plt.hist(data, bins, ec='black')
plt.xticks(ticks)
plt.xlim(lims)

plt.savefig(f"{Path(argv[0]).stem}.svg")
plt.show()