Python seaborn 模块,lmplot() 实例源码

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

项目:Tensorflow-Turitors    作者:Xls1994    | 项目源码 | 文件源码
def testData():
    num_puntos =2000
    conjunto_puntos =[]
    for i in range(num_puntos):
        if np.random.random()>0.5:
            x,y =np.random.normal(0.0,0.9),np.random.normal(0.0,0.9)
            conjunto_puntos.append([x,y])
        else:
            x, y = np.random.normal(3.0, 0.5), np.random.normal(1.0, 0.5)
            conjunto_puntos.append([x, y])
    df =pd.DataFrame({'x':[v[0] for v in conjunto_puntos],'y':
                      [v[1] for v in conjunto_puntos]})
    sns.lmplot('x','y',data=df,fit_reg=False,size=6)
    plt.show()

############??????###############
项目:newsrecommender    作者:Newsrecommender    | 项目源码 | 文件源码
def visualize_data(self):
        """
        Transform the DataFrame to the 2-dimensional case and visualizes the data. The first tags are used as labels.
        :return:
        """
        logging.debug("Preparing visualization of DataFrame")
        # Reduce dimensionality to 2 features for visualization purposes
        X_visualization = self.reduce_dimensionality(self, self.X, n_features=2)
        df = self.prepare_dataframe(X_visualization)
        # Set X and Y coordinate for each articles
        df['X coordinate'] = df['coordinates'].apply(lambda x: x[0])# shwenag ...No clue whats happening??
        df['Y coordinate'] = df['coordinates'].apply(lambda x: x[1])# shwenag ...No clue whats happening??
        '''
        # Create a list of markers, each tag has its own marker
        n_tags_first = len(self.df['tags_first'].unique())
        markers_choice_list = ['o', 's', '^', '.', 'v', '<', '>', 'D']
        markers_list = [markers_choice_list[i % 8] for i in range(n_tags_first)]
        '''
        # Create scatter plot
        sns.lmplot("X coordinate",
                   "Y coordinate",
                   #hue="tags_first",#commented by shwenag
                   data=df,
                   fit_reg=False,
                   #markers=markers_list,#commented by shwenag
                   scatter_kws={"s": 150})
        # Adjust borders and add title
        sns.set(font_scale=2)
        sns.plt.title('Visualization of  articles in a 2-dimensional space')
        sns.plt.subplots_adjust(right=0.80, top=0.90, left=0.12, bottom=0.12)
        # Show plot
        sns.plt.show()
项目:newsrecommender    作者:Newsrecommender    | 项目源码 | 文件源码
def visualize_data(self):
        """
        Transform the DataFrame to the 2-dimensional case and visualizes the data. The first tags are used as labels.
        :return:
        """
        logging.debug("Preparing visualization of DataFrame")
        # Reduce dimensionality to 2 features for visualization purposes
        X_visualization = self.reduce_dimensionality(self, self.X, n_features=2)
        df = self.prepare_dataframe(X_visualization)
        # Set X and Y coordinate for each articles
        df['X coordinate'] = df['coordinates'].apply(lambda x: x[0])# shwenag ...No clue whats happening??
        df['Y coordinate'] = df['coordinates'].apply(lambda x: x[1])# shwenag ...No clue whats happening??
        '''
        # Create a list of markers, each tag has its own marker
        n_tags_first = len(self.df['tags_first'].unique())
        markers_choice_list = ['o', 's', '^', '.', 'v', '<', '>', 'D']
        markers_list = [markers_choice_list[i % 8] for i in range(n_tags_first)]
        '''
        # Create scatter plot
        sns.lmplot("X coordinate",
                   "Y coordinate",
                   #hue="tags_first",#commented by shwenag
                   data=df,
                   fit_reg=False,
                   #markers=markers_list,#commented by shwenag
                   scatter_kws={"s": 150})
        # Adjust borders and add title
        sns.set(font_scale=2)
        sns.plt.title('Visualization of  articles in a 2-dimensional space')
        sns.plt.subplots_adjust(right=0.80, top=0.90, left=0.12, bottom=0.12)
        # Show plot
        sns.plt.show()
项目:scrap    作者:BruceJohnJennerLawso    | 项目源码 | 文件源码
def plotScatterLabelled(data, x_param, y_param, huey, output_path, output_directory, output_filename):
    sns.lmplot(x_param, y_param, data, hue=huey, fit_reg=False);
    output_ = "%s/%s/%s" % (output_path, output_directory, output_filename)
    try:
        plt.savefig(output_)
    except IOError:
        os.makedirs('%s/%s/' % (output_path, output_directory))
        plt.savefig(output_)    
    plt.close()
项目:pgsm    作者:aroth85    | 项目源码 | 文件源码
def plot_clustering(clustering, data, title):
    plot_df = pd.DataFrame(data, columns=['0', '1'])
    plot_df['cluster'] = clustering
    g = sb.lmplot(x='0', y='1', data=plot_df, hue='cluster', fit_reg=False)
    g.ax.set_title(title)
    pp.draw()
项目:themarketingtechnologist    作者:thomhopmans    | 项目源码 | 文件源码
def visualize_data(self):
        """
        Transform the DataFrame to the 2-dimensional case and visualizes the data. The first tags are used as labels.
        :return:
        """
        logging.debug("Preparing visualization of DataFrame")
        # Reduce dimensionality to 2 features for visualization purposes
        X_visualization = self.reduce_dimensionality(self.X, n_features=2)
        df = self.prepare_dataframe(X_visualization)
        # Set X and Y coordinate for each articles
        df['X coordinate'] = df['coordinates'].apply(lambda x: x[0])
        df['Y coordinate'] = df['coordinates'].apply(lambda x: x[1])
        # Create a list of markers, each tag has its own marker
        n_tags_first = len(self.df['tags_first'].unique())
        markers_choice_list = ['o', 's', '^', '.', 'v', '<', '>', 'D']
        markers_list = [markers_choice_list[i % 8] for i in range(n_tags_first)]
        # Create scatter plot
        sns.lmplot("X coordinate",
                   "Y coordinate",
                   hue="tags_first",
                   data=df,
                   fit_reg=False,
                   markers=markers_list,
                   scatter_kws={"s": 150})
        # Adjust borders and add title
        sns.set(font_scale=2)
        sns.plt.title('Visualization of TMT articles in a 2-dimensional space')
        sns.plt.subplots_adjust(right=0.80, top=0.90, left=0.12, bottom=0.12)
        # Show plot
        sns.plt.show()

    # Train recommender