當前位置: 首頁>>代碼示例>>Python>>正文


Python cm.rainbow方法代碼示例

本文整理匯總了Python中matplotlib.pyplot.cm.rainbow方法的典型用法代碼示例。如果您正苦於以下問題:Python cm.rainbow方法的具體用法?Python cm.rainbow怎麽用?Python cm.rainbow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在matplotlib.pyplot.cm的用法示例。


在下文中一共展示了cm.rainbow方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: getcolors

# 需要導入模塊: from matplotlib.pyplot import cm [as 別名]
# 或者: from matplotlib.pyplot.cm import rainbow [as 別名]
def getcolors(number):
    return list(cm.rainbow(linspace(0, 1, number))) 
開發者ID:kramerfelix,項目名稱:accpy,代碼行數:4,代碼來源:plot.py

示例2: plotdisptraj

# 需要導入模塊: from matplotlib.pyplot import cm [as 別名]
# 或者: from matplotlib.pyplot.cm import rainbow [as 別名]
def plotdisptraj(s, P_UCS, E, E0, UCS, UC, diagnostics):
    # measured energy dependant offset at FOMS normalized to 0 for EbE0=1
    xf1t = lambda EbE0: -.078269*EbE0 + .078269     # + .059449
    xf2t = lambda EbE0: -.241473*EbE0 + .241473     # + .229314
    xf6t = lambda EbE0: 1.174523*EbE0 - 1.174523    # - 1.196090
    xf7t = lambda EbE0: .998679*EbE0 - .998679      # - 1.018895
    xf8t = lambda EbE0: .769875*EbE0 - .769875      # - .787049
    steps = 6
    X = [empty([6, P_UCS+1]) for i in range(steps)]
    dEbE = linspace(-0.005, 0.005, steps)
    for deltaE, i in zip(dEbE, range(steps)):
        # R calculated for every energy (not necessary)
        gamma = (E+deltaE*E)/E0+1
        R = UCS2R(P_UCS, UCS, gamma)
        X[i][:, 0] = array([0, 0, 0, 0, 0, deltaE])
        X[i] = trackpart(X[i], R, P_UCS, P_UCS)*1e3
    fig = Figure()
    ax = fig.add_subplot(1, 1, 1)
    drawlattice(ax, UC, diagnostics, X, 0)
    ax.set_xlabel(r'orbit position s / (m)')
    ax.set_ylabel(r'radial displacement / (mm)')
    x = [s[UCS[0, :] == 7][i] for i in [0, 1, 5, 6, 7]]
    color = iter(cm.rainbow(linspace(0, 1, steps)))
    for i in range(steps):
        c = next(color)
        EE0 = 1 + dEbE[i]
        y = array([xf1t(EE0), xf2t(EE0), xf6t(EE0), xf7t(EE0), xf8t(EE0)])*1e3
        ax.plot(x, y, 'o', c=c)
        ax.plot(s, X[i][0, :], c=c, label=r'$\delta={:g}$\textperthousand'.format(dEbE[i]*1e3))
    ax.plot([], [], 'ok', label=r'measured')
    #ax.get_xaxis().set_visible(False)
    #leg = ax.legend(fancybox=True, loc=0)
    #leg.get_frame().set_alpha(0.5)
    ax.set_xlim([0, nanmax(s)])
    return fig 
開發者ID:kramerfelix,項目名稱:accpy,代碼行數:37,代碼來源:plot.py

示例3: plot_stuff

# 需要導入模塊: from matplotlib.pyplot import cm [as 別名]
# 或者: from matplotlib.pyplot.cm import rainbow [as 別名]
def plot_stuff(save=None):
    colors=cm.rainbow(np.linspace(0,1,10))

    valid_set, valid_labels = data.valid_batch(2000)

    class_embeddings = np.array(embedding_fn(valid_set))
    plt.figure(figsize=(18,9))
    for cls, color in zip(range(10),colors):
        current_points = class_embeddings[valid_labels==cls]
        if save is not None:
            plt.title('Iteration {}'.format(save))
        plt.subplot(121).scatter(current_points[:,0], current_points[:,1],
                    c=color, #valid_labels[valid_labels==cls],
                    marker='${}$'.format(cls), s=100, linewidths=0.1, edgecolor='black')
        plt.subplot(121).set_xlim([-1, 1])
        plt.subplot(121).set_ylim([-1, 1])
        current_points /= np.sqrt((current_points * current_points).sum(axis=1)).reshape(current_points.shape[0], 1)
        plt.subplot(122).scatter(current_points[:1000,0], current_points[:1000,1],
                c=color, #valid_labels[valid_labels==cls],
                marker='${}$'.format(cls), s=100, linewidths=0.1, edgecolor='black')
    plt.legend()
    if save is not None:
        plt.savefig('pics/{}.png'.format(save))
        plt.close()
    else:
        plt.show() 
開發者ID:brotherofken,項目名稱:no_fuss_dml,代碼行數:28,代碼來源:mnist.py

示例4: _get_color_dict

# 需要導入模塊: from matplotlib.pyplot import cm [as 別名]
# 或者: from matplotlib.pyplot.cm import rainbow [as 別名]
def _get_color_dict(baseline_tagger, cFraction):
    from matplotlib.pyplot import cm

    color_dict = {}
    color=iter(cm.rainbow(np.linspace(0,1,len(cFraction))))
    for c_fraction in cFraction:
        c=next(color)
        color_dict.update({"DL1c"+str(int(c_fraction*100.)): c,})

    color_dict.update({baseline_tagger: "black"})
    return color_dict 
開發者ID:Marie89,項目名稱:BTagging_DL1,代碼行數:13,代碼來源:PlotROC.py


注:本文中的matplotlib.pyplot.cm.rainbow方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。