Created
June 14, 2017 15:18
-
-
Save michaelsilverstein/1dac6d8ef1c84ec5234b9f2bfb29979e to your computer and use it in GitHub Desktop.
Seaborn pairplot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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