Python seaborn.stripplot() Examples
The following are 13
code examples of seaborn.stripplot().
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: brute_force_plotter.py From brute-force-plotter with MIT License | 7 votes |
def bar_box_violin_dot_plots(data, category_col, numeric_col, axes, file_name=None): sns.barplot(category_col, numeric_col, data=data, ax=axes[0]) sns.boxplot( category_col, numeric_col, data=data[data[numeric_col].notnull()], ax=axes[2] ) sns.violinplot( category_col, numeric_col, data=data, kind="violin", inner="quartile", scale="count", split=True, ax=axes[3], ) sns.stripplot(category_col, numeric_col, data=data, jitter=True, ax=axes[1]) sns.despine(left=True)
Example #2
Source File: umbilical.py From geosketch with MIT License | 6 votes |
def violin_jitter(X, genes, gene, labels, focus, background=None, xlabels=None): gidx = list(genes).index(gene) focus_idx = focus == labels if background is None: background_idx = focus != labels else: background_idx = background == labels if xlabels is None: xlabels = [ 'Background', 'Focus' ] x_gene = X[:, gidx].toarray().flatten() x_focus = x_gene[focus_idx] x_background = x_gene[background_idx] plt.figure() sns.violinplot(data=[ x_focus, x_background ], scale='width', cut=0) sns.stripplot(data=[ x_focus, x_background ], jitter=True, color='black', size=1) plt.xticks([0, 1], xlabels) plt.savefig('{}_violin_{}.png'.format(NAMESPACE, gene))
Example #3
Source File: plotting.py From smallrnaseq with GNU General Public License v3.0 | 6 votes |
def plot_read_count_dists(counts, h=8, n=50): """Boxplots of read count distributions """ scols,ncols = base.get_column_names(counts) df = counts.sort_values(by='mean_norm',ascending=False)[:n] df = df.set_index('name')[ncols] t = df.T w = int(h*(len(df)/60.0))+4 fig, ax = plt.subplots(figsize=(w,h)) if len(scols) > 1: sns.stripplot(data=t,linewidth=1.0,palette='coolwarm_r') ax.xaxis.grid(True) else: df.plot(kind='bar',ax=ax) sns.despine(offset=10,trim=True) ax.set_yscale('log') plt.setp(ax.xaxis.get_majorticklabels(), rotation=90) plt.ylabel('read count') #print (df.index) #plt.tight_layout() fig.subplots_adjust(bottom=0.2,top=0.9) return fig
Example #4
Source File: recipe_recommendation.py From Flavor-Network with GNU General Public License v3.0 | 6 votes |
def plot_similardishes(idx,xlim): match = yum_ingr2.iloc[yum_cos[idx].argsort()[-21:-1]][::-1] newidx = match.index.get_values() match['cosine'] = yum_cos[idx][newidx] match['rank'] = range(1,1+len(newidx)) label1, label2 =[],[] for i in match.index: label1.append(match.ix[i,'cuisine']) label2.append(match.ix[i,'recipeName']) fig = plt.figure(figsize=(10,10)) ax = sns.stripplot(y='rank', x='cosine', data=match, jitter=0.05, hue='cuisine',size=15,orient="h") ax.set_title(yum_ingr2.ix[idx,'recipeName']+'('+yum_ingr2.ix[idx,'cuisine']+')',fontsize=18) ax.set_xlabel('Flavor cosine similarity',fontsize=18) ax.set_ylabel('Rank',fontsize=18) ax.yaxis.grid(color='white') ax.xaxis.grid(color='white') for label, y,x, in zip(label2, match['rank'],match['cosine']): ax.text(x+0.001,y-1,label, ha = 'left') ax.legend(loc = 'lower right',prop={'size':14}) ax.set_ylim([20,-1]) ax.set_xlim(xlim)
Example #5
Source File: distanceWeightStatistic.py From python-urbanPlanning with MIT License | 6 votes |
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 #6
Source File: mouse_brain_subcluster.py From geosketch with MIT License | 5 votes |
def astro_oligo_violin(X, genes, gene, labels, name): X = X.toarray() gidx = list(genes).index(gene) astro = X[labels == 'astro', gidx] oligo = X[labels == 'oligo', gidx] both = X[labels == 'both', gidx] plt.figure() sns.violinplot(data=[ astro, oligo, both ], scale='width', cut=0) sns.stripplot(data=[ astro, oligo, both ], jitter=True, color='black', size=1) plt.xticks([0, 1, 2], ['Astrocytes', 'Oligodendrocytes', 'Both']) plt.savefig('{}_violin_{}.svg'.format(name, gene))
Example #7
Source File: mouse_brain_astrocyte.py From geosketch with MIT License | 5 votes |
def astro_oligo_violin(X, genes, gene, labels, name): X = X.toarray() gidx = list(genes).index(gene) astro = X[labels == 'astro', gidx] oligo = X[labels == 'oligo', gidx] both = X[labels == 'both', gidx] plt.figure() sns.violinplot(data=[ astro, oligo, both ], scale='width', cut=0) sns.stripplot(data=[ astro, oligo, both ], jitter=True, color='black', size=1) plt.xticks([0, 1, 2], ['Astrocytes', 'Oligodendrocytes', 'Both']) plt.savefig('{}_violin_{}.svg'.format(name, gene))
Example #8
Source File: imputations.py From autoimpute with MIT License | 5 votes |
def plot_imp_strip(d, mi, imp_col, palette=None, title="Imputation Strip", **plot_kwgs): """Create the strip plot for multiply imputed data. Args: d (list): dataset returned from multiple imputation. mi (MultipleImputer): multiple imputer used to generate d. imp_col (str): column to plot. Should be a column with imputations. title (str, Optional): title of plot. Default is "Imputation Strip". palette (list, tuple, Optional): colors for the imps and observed. Default is None. if None, colors default to ["r","c"]. **plot_kwgs: keyword arguments used by sns.set. Returns: sns.distplot: stripplot for imputed data Raises: ValueError: see _validate_data method. """ # set plot type, validate, and define names necessary _default_plot_args(**plot_kwgs) _validate_data(d, mi, imp_col) datasets_merged = _melt_df(d, mi, imp_col) if palette is None: palette = ["r", "c"] # stripplot example sns.stripplot( x="imp_num", y=imp_col, hue="imputed", palette=palette, data=datasets_merged, jitter=True, hue_order=["yes", "no"], dodge=True ).set(xlabel="Imputation Number", title=title)
Example #9
Source File: sf_heatmap.py From pancanatlas_code_public with MIT License | 5 votes |
def run_strip_plot(panc_df, gtex_df, panc_labels, gtex_labels): assert panc_df.columns.equals(gtex_df.columns) psi_df = pd.concat((panc_df, gtex_df), axis=0) assert psi_df.shape[0] == panc_df.shape[0] + gtex_df.shape[0] assert psi_df.columns.unique().size == psi_df.shape[1] assert panc_df.index.equals(panc_labels.index) assert gtex_df.index.equals(gtex_labels.index) event_list = psi_df.columns.tolist() psi_df_aug = psi_df.copy() psi_df_aug['cnc'] = None psi_df_aug.loc[panc_df.index, ['cnc']] = panc_labels.loc[panc_df.index] psi_df_aug.loc[gtex_df.index, ['cnc']] = gtex_labels.loc[gtex_df.index] unq_panc_labels = sorted(panc_labels.unique().tolist()) unq_gtex_labels = sorted(gtex_labels.unique().tolist()) assert np.intersect1d(unq_panc_labels, unq_gtex_labels).size == 0 plt.close() label_list = unq_panc_labels + unq_gtex_labels color_lut = _get_stripplot_color_lut(unq_panc_labels, unq_gtex_labels) for event in event_list: outpath = os.path.join(PLOT_DIR, 'stripplots', '%s_stripplot.png'%event) if not os.path.exists(os.path.dirname(outpath)): os.makedirs(os.path.dirname(outpath)) fig, ax = plt.subplots(figsize=(20,3)) sns.stripplot(x='cnc', y=event, data=psi_df_aug, palette=color_lut, s=3, order=label_list, jitter=True, ax=ax) ax.axvline(len(unq_panc_labels) - .5, color='black', ls='--') ax.set_xticklabels(ax.get_xticklabels(), rotation = 90) ax.set_ylim(-.05, 1.05) ax.title.set_text('Gene: %s Event type: %s Event ID: %d'%(_decode_event_name(event))) ax.set_ylabel('psi') ax.set_xlabel('') axs.clean_axis(ax) print "Writing: %s" %outpath plt.savefig(outpath, bbox_inches='tight') pdf_outpath = re.sub('.png$', '.pdf', outpath) print "Writing: %s" %pdf_outpath plt.savefig(pdf_outpath, bbox_inches='tight') plt.close() return
Example #10
Source File: plot.py From speedml with MIT License | 5 votes |
def strip(self, x, y): """ Stripplot plot ``x`` across ``y`` feature values. """ plt.figure(figsize=(8,4)) sns.stripplot(x, y, hue=Base.target, data=Base.train, jitter=True) plt.xlabel(x, fontsize=12) plt.ylabel(y, fontsize=12) plt.show();
Example #11
Source File: valueWeightStatistic_merge.py From python-urbanPlanning with MIT License | 4 votes |
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 #12
Source File: distanceWeightCalculation_raster2Polygon.py From python-urbanPlanning with MIT License | 4 votes |
def visualisationDF(df): dataFrameInfoPrint(df) #graph-01 # df['shapelyArea'].plot.hist(alpha=0.5) #graph-02 # df['shapelyArea'].plot.kde() #graph-03 # df[['shapelyLength','shapeIdx']].plot.scatter('shapelyLength','shapeIdx') #normalize data in a range of columns cols_to_norm=['shapeIdx', 'FRAC'] df[cols_to_norm]=df[cols_to_norm].apply(lambda x: (x - x.min()) / (x.max() - x.min())) a='shapeIdx' b='FRAC' c='park_class' #graph-04 # sns.jointplot(a,b,df,kind='hex') #graph-05 # sns.jointplot(a, b, df, kind='kde') #graph-06 # sns.catplot(x='park_class',y=a,data=df) #graph-07 ''' # Initialize the figure f, ax = plt.subplots() sns.despine(bottom=True, left=True) # Show each observation with a scatterplot sns.stripplot(x=a, y=c, hue=c,data=df, dodge=True, alpha=.25, zorder=1) # Show the conditional means sns.pointplot(x=a, y=c, hue=c,data=df, dodge=.532, join=False, palette="dark",markers="d", scale=.75, ci=None) # Improve the legend handles, labels = ax.get_legend_handles_labels() ax.legend(handles[3:], labels[3:], title=b,handletextpad=0, columnspacing=1,loc="lower right", ncol=3, frameon=True) ''' #graph-08 # sns.catplot(x=c,y=a,data=df,kind='box') #graph-09 # sns.catplot(x=c,y=a,data=df,kind='violin') #graph-10 ''' f, axs = plt.subplots(1, 2, figsize=(12, 6)) # First axis df[b].plot.hist(ax=axs[0]) # Second axis df[b].plot.kde(ax=axs[1]) # Title f.suptitle(b) # Display plt.show() ''' #从新定义栅格投影,参考投影为vector .shp文件
Example #13
Source File: valueWeightStatistic_merge.py From python-urbanPlanning with MIT License | 4 votes |
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