import numpy as np
import matplotlib.pyplot as plt
from grains2 import PowerLaw, Hanner

a = np.logspace(-1, 3, 1000)
k = -3
pl = PowerLaw(k).dnda(a)
h = Hanner(a[0], N=-k, ap=1.0).dnda(a)

fig, ax = plt.subplots()
ax.plot(a, pl, label="Power law (N=–3)")
ax.plot(a, h, label="Hanner-modified power law ($a_p$=1.0 μm)")
ax.legend()
plt.setp(
    ax,
    xlabel="Radius (μm)",
    xscale="log",
    xlim=(0.1, 1000),
    ylabel="$dn/da$",
    yscale="log",
    ylim=(1e-9, 1e3)
)
plt.tight_layout()