Skip to content

Instantly share code, notes, and snippets.

@michaelsilverstein
Created June 14, 2017 15:18
Show Gist options
  • Save michaelsilverstein/1dac6d8ef1c84ec5234b9f2bfb29979e to your computer and use it in GitHub Desktop.
Save michaelsilverstein/1dac6d8ef1c84ec5234b9f2bfb29979e to your computer and use it in GitHub Desktop.
Seaborn pairplot
def pairplot(df,strain,hue=None,view='show'):
#Pairplot http://seaborn.pydata.org/generated/seaborn.pairplot.html
#hue: color plot by 'condition' (on). Default None (off)
print 'Generating pairplot for %s...'%strain
cols = list(df.columns)
cols.remove('concentration') #No need to clutter
if type(df.condition.iloc[0]) != str: #Apply condition name
df.condition = df.condition.apply(lambda x: code[x])# code={0:'Wm',1:'Wc',2:'Wmc'}
sns.pairplot(df[cols][df.strain==strain],hue=hue)
plt.title(strain)
if view == 'show':
plt.show()
else:
plt.savefig('pairplots/%s_pairplot'%strain)
plt.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment