Python之Seaborn

install:  

pip install seaborn

 

official examples: https://seaborn.pydata.org/examples/index.html

 

在mac上的bug:

在mac上运行会出现warnings.warn("tight_layout : falling back to Agg renderer")

需要在tight_layout()前添加plt.show(),如果tight_layout()被内置到了API中,我就不知道怎么办了。例子:

import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt

sns.set(style="dark")
rs = np.random.RandomState(50)

# Set up the matplotlib figure
f, axes = plt.subplots(3, 3, figsize=(9, 9), sharex=True, sharey=True)

# Rotate the starting point around the cubehelix hue circle
for ax, s in zip(axes.flat, np.linspace(0, 3, 10)):

    # Create a cubehelix colormap to use with kdeplot
    cmap = sns.cubehelix_palette(start=s, light=1, as_cmap=True)

    # Generate and plot a random bivariate dataset
    x, y = rs.randn(2, 50)
    sns.kdeplot(x, y, cmap=cmap, shade=True, cut=5, ax=ax)
    ax.set(xlim=(-3, 3), ylim=(-3, 3))
plt.show()  # I just add this line, and it works
f.tight_layout()

 

posted @ 2017-03-25 18:44  Shiyu_Huang  阅读(1023)  评论(0编辑  收藏  举报