Guest User

Untitled

a guest
May 27th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. import seaborn as sns
  2. import pandas as pd
  3.  
  4. def make_lower_pairplot(tmp, plot_unit_line=True, corrs_method = 'spearman'):
  5. try:
  6. g = sns.pairplot(tmp)
  7. except FloatingPointError as e:
  8. warnings.warn(e.args)
  9. return tmp
  10. g.map_upper(lambda x, y, **kwargs: pl.gca().set_visible(False));
  11. if plot_unit_line:
  12. g.map_lower(lambda x, y, **kwargs: pl.plot([0,1], [0,1], '--r'))
  13.  
  14. for i in range(g.axes.shape[0]):
  15. g.axes[i, i].set_visible(False)
  16. g.diag_axes[i].set_visible(False)
  17.  
  18. corrs = tmp.corr(method=corrs_method)
  19. for i in range(g.axes.shape[0]):
  20. for j in range(i):
  21. ax = g.axes[i ,j]
  22. ax.text(0.05, 1, "r = {:.2f}".format(corrs.iloc[i,j]), color='red', transform=ax.transAxes)
Add Comment
Please, Sign In to add comment