Guest User

Untitled

a guest
Oct 23rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. import numpy as np
  2. import pandas as pd
  3. import seaborn as sns
  4. import matplotlib.pyplot as plt
  5. sns.set(style="white", rc={"axes.facecolor": (0, 0, 0, 0)})
  6.  
  7. # Create the data
  8. rs = np.random.RandomState(1979)
  9. x = rs.randn(500)
  10. g = np.tile(list("ABCDEFGHIJ"), 50)
  11. df = pd.DataFrame(dict(x=x, g=g))
  12. m = df.g.map(ord)
  13. df["x"] += m
  14.  
  15. # Initialize the FacetGrid object
  16. pal = sns.cubehelix_palette(10, rot=-.25, light=.7)
  17. g = sns.FacetGrid(df, row="g", hue="g", aspect=15, height=.5, palette=pal)
  18.  
  19. # Draw the densities in a few steps
  20. g.map(sns.kdeplot, "x", clip_on=False, shade=True, alpha=1, lw=1.5, bw=.2)
  21. g.map(sns.kdeplot, "x", clip_on=False, color="w", lw=2, bw=.2)
  22. g.map(plt.axhline, y=0, lw=2, clip_on=False)
  23.  
  24. # Define and use a simple function to label the plot in axes coordinates
  25. def label(x, color, label):
  26. ax = plt.gca()
  27. ax.text(0, .2, label, fontweight="bold", color=color,
  28. ha="left", va="center", transform=ax.transAxes)
  29.  
  30. g.map(label, "x")
  31.  
  32. # Set the subplots to overlap
  33. g.fig.subplots_adjust(hspace=-.25)
  34.  
  35. # Remove axes details that don't play well with overlap
  36. g.set_titles("")
  37. g.set(yticks=[])
  38. g.despine(bottom=True, left=True)
Add Comment
Please, Sign In to add comment