Python seaborn.PairGrid() Examples

The following are 7 code examples of seaborn.PairGrid(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module seaborn , or try the search function .
Example #1
Source File: visualizations.py    From Brancher with MIT License 7 votes vote down vote up
def plot_posterior(model, variables, number_samples=1000):

    # Get samples
    sample = model.get_sample(number_samples)
    post_sample = model.get_posterior_sample(number_samples)

    # Join samples
    sample["Mode"] = "Prior"
    post_sample["Mode"] = "Posterior"
    subsample = sample[variables + ["Mode"]]
    post_subsample = post_sample[variables + ["Mode"]]
    joint_subsample = subsample.append(post_subsample)

    # Plot posterior
    warnings.filterwarnings('ignore')
    g = sns.PairGrid(joint_subsample, hue="Mode")
    g = g.map_offdiag(sns.kdeplot)
    g = g.map_diag(sns.kdeplot, lw=3, shade=True)
    g = g.add_legend()
    warnings.filterwarnings('default') 
Example #2
Source File: visualizations.py    From Brancher with MIT License 6 votes vote down vote up
def plot_posterior_histogram(model, variables, number_samples=300): #TODO: fix code duplication

    # Get samples
    sample = model.get_sample(number_samples)
    post_sample = model.get_posterior_sample(number_samples)

    # Join samples
    sample["Mode"] = "Prior"
    post_sample["Mode"] = "Posterior"
    subsample = sample[variables + ["Mode"]]
    post_subsample = post_sample[variables + ["Mode"]]
    joint_subsample = subsample.append(post_subsample)

    # Plot posterior
    warnings.filterwarnings('ignore')
    g = sns.PairGrid(joint_subsample, hue="Mode")
    g = g.map_offdiag(sns.distplot)
    g = g.map_diag(sns.distplot)
    g = g.add_legend()
    warnings.filterwarnings('default') 
Example #3
Source File: plotting.py    From fitbit-analyzer with Apache License 2.0 6 votes vote down vote up
def plotCorrelation(stats):
    #columnsToDrop = ['sleep_interval_max_len', 'sleep_interval_min_len',
    #                 'sleep_interval_avg_len', 'sleep_inefficiency',
    #                 'sleep_hours', 'total_hours']

    #stats = stats.drop(columnsToDrop, axis=1)

    g = sns.PairGrid(stats)
    def corrfunc(x, y, **kws):
        r, p = scipystats.pearsonr(x, y)
        ax = plt.gca()
        ax.annotate("r = {:.2f}".format(r),xy=(.1, .9), xycoords=ax.transAxes)
        ax.annotate("p = {:.2f}".format(p),xy=(.2, .8), xycoords=ax.transAxes)
        if p>0.04:
            ax.patch.set_alpha(0.1)

    g.map_upper(plt.scatter)
    g.map_diag(plt.hist)
    g.map_lower(sns.kdeplot, cmap="Blues_d")
    g.map_upper(corrfunc)
    sns.plt.show() 
Example #4
Source File: distanceWeightStatistic.py    From python-urbanPlanning with MIT License 6 votes vote down vote up
def geoValueWeightedVisulization(valueDes):
    valueDes["ID"]=valueDes.index
    sns.set(style="whitegrid")
    # Make the PairGrid
    extractedColumns=["count","mean","std","max"]
    g=sns.PairGrid(valueDes.sort_values("count", ascending=False),x_vars=extractedColumns, y_vars=["ID"],height=10, aspect=.25)
    # Draw a dot plot using the stripplot function
    g.map(sns.stripplot, size=10, orient="h",palette="ch:s=1,r=-.1,h=1_r", linewidth=1, edgecolor="w")    
    # Use the same x axis limits on all columns and add better labels
    g.set(xlabel="value", ylabel="") #g.set(xlim=(0, 25), xlabel="Crashes", ylabel="")
    # Use semantically meaningful titles for the columns
    titles=valueDes.columns.tolist() 
    for ax, title in zip(g.axes.flat, titles):
        # Set a different title for each axes
        ax.set(title=title)
        # Make the grid horizontal instead of vertical
        ax.xaxis.grid(False)
        ax.yaxis.grid(True)
    sns.despine(left=True, bottom=True) 
Example #5
Source File: visualizations.py    From Brancher with MIT License 5 votes vote down vote up
def plot_density(model, variables, number_samples=2000):
    sample = model.get_sample(number_samples)
    warnings.filterwarnings('ignore')
    g = sns.PairGrid(sample[variables])
    g = g.map_offdiag(sns.kdeplot)
    g = g.map_diag(sns.kdeplot, lw=3, shade=True)
    g = g.add_legend()
    warnings.filterwarnings('default') 
Example #6
Source File: valueWeightStatistic_merge.py    From python-urbanPlanning with MIT License 4 votes vote down vote up
def geoValVisulization_a(geoPd):
    geoPd["ID"]=geoPd.index.astype(str)
    print(geoPd.columns)
    '''
Index(['park_no', 'label', 'park_class', 'location', 'acres', 'shape_area',
       'shape_leng', 'perimeter', 'geometry', 'shapelyArea', 'shapelyLength',
       'shapeIdx', 'FRAC', 'popu_count', 'popu_mean', 'popu_std', 'popu_min',
       'popu_25%', 'popu_50%', 'popu_75%', 'popu_max', 'SVFW_count',
       'SVFW_mean', 'SVFW_std', 'SVFW_min', 'SVFW_25%', 'SVFW_50%', 'SVFW_75%',
       'SVFW_max', 'polyID', 'SVFep_min', 'SVFep_max', 'SVFep_mean',
       'SVFep_count', 'SVFep_sum', 'SVFep_std', 'SVFep_median',
       'SVFep_majority', 'SVFep_minority', 'SVFep_unique', 'SVFep_range',
       'SVFep_nodata', 'HVege_min', 'HVege_max', 'HVege_mean', 'HVege_count',
       'HVege_sum', 'HVege_std', 'HVege_median', 'HVege_majority',
       'HVege_minority', 'HVege_range', 'HVege_nodata', 'MVege_min',
       'MVege_max', 'MVege_mean', 'MVege_count', 'MVege_sum', 'MVege_std',
       'MVege_median', 'MVege_majority', 'MVege_minority', 'MVege_range',
       'MVege_nodata', 'LVege_min', 'LVege_max', 'LVege_mean', 'LVege_count',
       'LVege_sum', 'LVege_std', 'LVege_median', 'LVege_majority',
       'LVege_minority', 'LVege_range', 'LVege_nodata', 'facilityFre',
       'facilityID', 'cla_treeCanopy', 'cla_grassShrub', 'cla_bareSoil',
       'cla_buildings', 'cla_roadsRailraods', 'cla_otherPavedSurfaces',
       'cla_water', 'classi_count', 'ID'],
      dtype='object')
    '''
    sns.set(style="whitegrid")
    
    # Make the PairGrid
    extractedColumns=['shapelyArea','shapelyLength',
                      'shapeIdx','FRAC',
                      'SVFW_mean','SVFW_std',
                      'SVFW_mean','SVFW_std',
                      'popu_std','popu_mean',                      
                      'facilityFre',
                      'classi_count','cla_treeCanopy', 'cla_grassShrub','cla_bareSoil', 'cla_buildings', 'cla_roadsRailraods', 'cla_otherPavedSurfaces','cla_water',
                      'HVege_count','HVege_mean',
                      'LVege_count','LVege_mean',
                      
                      ]
    # geoPdSort=geoPd.sort_values('shapelyArea', ascending=False)
    g=sns.PairGrid(geoPd.sort_values('shapelyArea', ascending=False),x_vars=extractedColumns, y_vars=["label"],height=20, aspect=.25)
    # g=sns.PairGrid(geoPd,x_vars=extractedColumns, y_vars=["ID"],height=20, aspect=.25)

    # Draw a dot plot using the stripplot function
    g.map(sns.stripplot, size=5, orient="h",palette="ch:s=1,r=-.1,h=1_r", linewidth=1, edgecolor="w")    
    # Use the same x axis limits on all columns and add better labels
    g.set(xlabel="value", ylabel="") #g.set(xlim=(0, 25), xlabel="Crashes", ylabel="")
    # Use semantically meaningful titles for the columns
    g.fig.set_figwidth(30)
    g.fig.set_figheight(80)
    
    titles=extractedColumns
    for ax, title in zip(g.axes.flat, titles):
        # Set a different title for each axes
        ax.set(title=title)
        # Make the grid horizontal instead of vertical
        ax.xaxis.grid(False)
        ax.yaxis.grid(True)
    sns.despine(left=True, bottom=True)        

    return geoPd 
Example #7
Source File: valueWeightStatistic_merge.py    From python-urbanPlanning with MIT License 4 votes vote down vote up
def geoValVisulization_a(geoPd):
    geoPd["ID"]=geoPd.index.astype(str)
    print(geoPd.columns)
    '''
Index(['park_no', 'label', 'park_class', 'location', 'acres', 'shape_area',
       'shape_leng', 'perimeter', 'geometry', 'shapelyArea', 'shapelyLength',
       'shapeIdx', 'FRAC', 'popu_count', 'popu_mean', 'popu_std', 'popu_min',
       'popu_25%', 'popu_50%', 'popu_75%', 'popu_max', 'SVFW_count',
       'SVFW_mean', 'SVFW_std', 'SVFW_min', 'SVFW_25%', 'SVFW_50%', 'SVFW_75%',
       'SVFW_max', 'polyID', 'SVFep_min', 'SVFep_max', 'SVFep_mean',
       'SVFep_count', 'SVFep_sum', 'SVFep_std', 'SVFep_median',
       'SVFep_majority', 'SVFep_minority', 'SVFep_unique', 'SVFep_range',
       'SVFep_nodata', 'HVege_min', 'HVege_max', 'HVege_mean', 'HVege_count',
       'HVege_sum', 'HVege_std', 'HVege_median', 'HVege_majority',
       'HVege_minority', 'HVege_range', 'HVege_nodata', 'MVege_min',
       'MVege_max', 'MVege_mean', 'MVege_count', 'MVege_sum', 'MVege_std',
       'MVege_median', 'MVege_majority', 'MVege_minority', 'MVege_range',
       'MVege_nodata', 'LVege_min', 'LVege_max', 'LVege_mean', 'LVege_count',
       'LVege_sum', 'LVege_std', 'LVege_median', 'LVege_majority',
       'LVege_minority', 'LVege_range', 'LVege_nodata', 'facilityFre',
       'facilityID', 'cla_treeCanopy', 'cla_grassShrub', 'cla_bareSoil',
       'cla_buildings', 'cla_roadsRailraods', 'cla_otherPavedSurfaces',
       'cla_water', 'classi_count', 'ID'],
      dtype='object')
    '''
    sns.set(style="whitegrid")
    
    # Make the PairGrid
    extractedColumns=['shapelyArea','shapelyLength',
                      'shapeIdx','FRAC',
                      'SVFW_mean','SVFW_std',
                      'SVFW_mean','SVFW_std',
                      'popu_std','popu_mean',                      
                      'facilityFre',
                      'classi_count','cla_treeCanopy', 'cla_grassShrub','cla_bareSoil', 'cla_buildings', 'cla_roadsRailraods', 'cla_otherPavedSurfaces','cla_water',
                      'HVege_count','HVege_mean',
                      'LVege_count','LVege_mean',
                      
                      ]
    # geoPdSort=geoPd.sort_values('shapelyArea', ascending=False)
    g=sns.PairGrid(geoPd.sort_values('shapelyArea', ascending=False),x_vars=extractedColumns, y_vars=["label"],height=20, aspect=.25)
    # g=sns.PairGrid(geoPd,x_vars=extractedColumns, y_vars=["ID"],height=20, aspect=.25)

    # Draw a dot plot using the stripplot function
    g.map(sns.stripplot, size=5, orient="h",palette="ch:s=1,r=-.1,h=1_r", linewidth=1, edgecolor="w")    
    # Use the same x axis limits on all columns and add better labels
    g.set(xlabel="value", ylabel="") #g.set(xlim=(0, 25), xlabel="Crashes", ylabel="")
    # Use semantically meaningful titles for the columns
    g.fig.set_figwidth(30)
    g.fig.set_figheight(80)
    
    titles=extractedColumns
    for ax, title in zip(g.axes.flat, titles):
        # Set a different title for each axes
        ax.set(title=title)
        # Make the grid horizontal instead of vertical
        ax.xaxis.grid(False)
        ax.yaxis.grid(True)
    sns.despine(left=True, bottom=True)        

    return geoPd