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


Python cm.Set1方法代碼示例

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


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

示例1: scatter_plot

# 需要導入模塊: from matplotlib import cm [as 別名]
# 或者: from matplotlib.cm import Set1 [as 別名]
def scatter_plot( self, **kwds ):
        '''
        Generates a scatter plot using the first 2 princpal components as axes.
        
        **Keywords**:
         - *vectors* = True if original axes should be plotted as vectors in this space. Default is False.
         - *path* = a path to save this figure to
         - *dpi* = the dpi of the saved figure
         - *width* = the width (in inches) of the saved figure
         - *height* = the height (in inches) of the saved figure
        '''
        #get 2d subspace
        ss = self.get_subspace(n=2)
        
        #calculate colours
        import matplotlib.cm as cm
        scale = 255 / (max(self.groups) + 1)
        c = cm.Set1(self.groups*scale,alpha=1)
        
        #plot scatterplot
        fig,ax = plt.subplots()
        ss.plot('PC1','PC2',kind='scatter',c=c,ax=ax)
        
        #plot vectors
        if (kwds.has_key('vectors')):
            if kwds['vectors'] == True:
                
                #calculate initial vectors (ie. identity matrix)
                axes=np.identity(len(self.data.columns))
        
                #project
                axes=self.project(axes,2)
                
                #plot
                for i,a in enumerate(axes):
                    x = [0,a[0]]
                    y = [0,a[1]]
                    ax.plot(x,y,label=self.data.columns[i])
                
                ax.legend()
                
    #private functions 
開發者ID:cgre-aachen,項目名稱:pynoddy,代碼行數:44,代碼來源:LDA.py

示例2: plot_cells

# 需要導入模塊: from matplotlib import cm [as 別名]
# 或者: from matplotlib.cm import Set1 [as 別名]
def plot_cells(cells, dx=1.0, **kwargs):
    """
    Plot the spatial receptive fields for multiple cells.

    Parameters
    ----------
    cells : list of array_like
        A list of spatiotemporal receptive fields, each of which is
        a spatiotemporal array.

    dx : float, optional
        The spatial sampling rate of the STA, setting the scale of the
        x- and y-axes.

    ax : matplotlib Axes object, optional
        The axes onto which the ellipse should be plotted.
        Defaults to a new figure.

    Returns
    ------
    fig : matplotlib.figure.Figure
        The figure onto which the ellipses are plotted.

    ax : matplotlib.axes.Axes
        The axes onto which the ellipses are plotted.
    """
    _ = kwargs.pop('fig')
    ax = kwargs.pop('ax')
    colors = cm.Set1(np.random.rand(len(cells),))

    # for each cell
    for color, sta in zip(colors, cells):

        # get the spatial profile
        try:
            spatial_profile = ft.decompose(sta)[0]
        except np.linalg.LinAlgError:
            continue

        # plot ellipse
        try:
            ellipse(spatial_profile, fc=color, ec=color,
                    lw=2, dx=dx, alpha=0.3, ax=ax)
        except RuntimeError:
            pass 
開發者ID:baccuslab,項目名稱:pyret,代碼行數:47,代碼來源:visualizations.py


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