Python matplotlib.cm 模块,autumn() 实例源码

我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用matplotlib.cm.autumn()

项目:SWEETer-Cat    作者:DanielAndreasen    | 项目源码 | 文件源码
def detail_plot(df, tlow, thigh):

    hz1 = get_default(df['hz1'].values[0], -2, float)
    hz2 = get_default(df['hz2'].values[0], -1, float)
    color = get_default(df['teff'].values[0], 5777, float)
    tlow = get_default(max(2500, tlow), 2500, int)
    thigh = get_default(min(8500, thigh), 8500, int)

    R = df.iloc[0]['radius']
    r = [planetary_radius(mi, ri) for mi, ri in df.loc[:, ['plMass', 'plRadius']].values]
    smas = df['sma'].values
    max_smas = max([smai for smai in smas if isinstance(smai, (int, float)) and not np.isnan(smai)])
    Rs = max(500, 500*R)
    rs = [max(80, 30*ri) for ri in r]

    fig, ax = plt.subplots(1, figsize=(14, 2))
    ax.scatter([0], [1], s=Rs, c=color, vmin=tlow, vmax=thigh, cmap=cm.autumn)
    no_sma = []

    if 0 < hz1 < hz2:
        x = np.linspace(hz1, hz2, 10)
        y = np.linspace(0.9, 1.1, 10)
        z = np.array([[xi]*10 for xi in x[::-1]]).T
        plt.contourf(x, y, z, 300, alpha=0.8, cmap=cm.summer)

    for i, sma in enumerate(smas):
        if np.isnan(sma):
            no_sma.append('{} has no SMA'.format(df['plName'].values[i]))
            continue
        if sma < hz1:
            dist = hz1-sma
            ax.scatter(sma, [1], s=rs[i], c=dist, vmin=0, vmax=hz1, cmap=cm.autumn)
        elif hz1 <= sma <= hz2:
            ax.scatter(sma, [1], s=rs[i], c='k', alpha=0.8)
        else:
            dist = sma-hz2
            ax.scatter(sma, [1], s=rs[i], c=dist, vmin=hz2, vmax=max_smas, cmap=cm.winter_r)

    for planet in ss_planets.keys():
        s = ss_planets[planet][0]
        r = 30*ss_planets[planet][1]/2.
        r /= float(ss_planets['Jupiter'][1])
        ax.scatter(s, [0.95], s=r*10, c='g')
        ax.text(s-0.01, 0.97, planet, color='white')

    ax.set_xlim(0.0, max_smas*1.2)
    ax.set_ylim(0.9, 1.1)
    ax.set_xlabel('Semi-major axis [AU]')
    ax.yaxis.set_major_formatter(plt.NullFormatter())
    ax.set_yticks([])
    ax.spines['left'].set_visible(False)
    ax.set_facecolor('black')
    plt.tight_layout()

    for i, text in enumerate(no_sma):
        ax.text(max_smas*0.8, 1.05-i*0.02, text, color='white')

    return fig_to_html(fig)