Example #1
0
def set_n_ticks(ax=None, nx=3, ny=2):
    """Set the number of major ticks for each axis"""
    if ax is None:
        ax = pl.gca()
    old_ax = pl.gca()
    pl.sca(ax)

    if ny is not None:
        pl.locator_params(axis='y', nbins=ny)

    if nx is not None:
        pl.locator_params(axis='x', nbins=nx)

    pl.sca(old_ax)
    i1 = np.where(t <= 12)[0][-1]
    _t = t[:i1 + 1]
    _cases = cases[:i1 + 1]
    print(t, cases)

    if len(t) < 8:
        continue

    f = lambda x, mu, B: B * (x)**mu
    p, _ = curve_fit(f, _t, _cases, [1.5, 4.5])

    print(p)

    tt = np.logspace(np.log(t[0]), np.log(t[-1]), base=np.exp(1))

    pl.sca(ax[i])

    ax[i].text(
        0.7,
        0.2,
        "$\mu={0:4.2f}$".format(p[0]),
        transform=ax[i].transAxes,
        ha='right',
        va='bottom',
        bbox={
            'facecolor': 'w',
            'edgecolor': 'w',
            'pad': 0
        },
        zorder=-1000,
    )