Python画核密度估计图之seaborn
1.核密度估计图。import matplotlib.pylab as pltimport seaborn as snsdf = sns.load_dataset('iris')p1=sns.kdeplot(df['sepal_width'])plt.show()import matplotlib.pylab as pltimport seaborn as snsdf = sns.load_dat
·
1.核密度估计图。
import matplotlib.pylab as plt
import seaborn as sns
df = sns.load_dataset('iris')
p1=sns.kdeplot(df['sepal_width'])
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
df = sns.load_dataset('iris')
p1=sns.kdeplot(df['sepal_width'], shade=True)
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
df = sns.load_dataset('iris')
p1=sns.kdeplot(df['sepal_width'], shade=True, vertical=True, color="skyblue")
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
df = sns.load_dataset('iris')
p1=sns.kdeplot(df['sepal_width'], shade=True, bw=.5, color="olive")
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
df = sns.load_dataset('iris')
p2=sns.kdeplot(df['sepal_width'], shade=True, bw=.05, color="olive")
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
df = sns.load_dataset('iris')
p1=sns.kdeplot(df['sepal_width'], shade=True, color="r")
p1=sns.kdeplot(df['sepal_length'], shade=True, color="b")
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
df = sns.load_dataset('iris')
sns.set_style("white")
p1 = sns.kdeplot(df.sepal_width, df.sepal_length)
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
df = sns.load_dataset('iris')
sns.set_style("white")
p1 = sns.kdeplot(df.sepal_width, df.sepal_length, cmap="Reds", shade=True, bw=.15)
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
df = sns.load_dataset('iris')
sns.set_style("white")
p1 = sns.kdeplot(df.sepal_width, df.sepal_length, cmap="Blues", shade=True, shade_lowest=True, )
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
df = sns.load_dataset('iris')
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
sns.jointplot(x=df["sepal_length"], y=df["sepal_width"])
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
df = sns.load_dataset('iris')
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
sns.jointplot(x=df["sepal_length"], y=df["sepal_width"], kind='hex')
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
df = sns.load_dataset('iris')
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
sns.jointplot(x=df["sepal_length"], y=df["sepal_width"], kind='kde')
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
df = sns.load_dataset('iris')
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
sns.jointplot(x=df["sepal_length"], y=df["sepal_width"], kind='scatter', s=200, color='m', edgecolor="skyblue", linewidth=2)
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
df = sns.load_dataset('iris')
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
sns.set(style="white", color_codes=True)
sns.jointplot(x=df["sepal_length"], y=df["sepal_width"], kind='kde', color="skyblue")
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
df = sns.load_dataset('iris')
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
sns.jointplot(x=df["sepal_length"], y=df["sepal_width"], kind='hex', marginal_kws=dict(bins=30, rug=True))
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
df = sns.load_dataset('iris')
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
sns.jointplot(x=df["sepal_length"], y=df["sepal_width"], kind='kde', color="grey", space=0)
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
df = sns.load_dataset('iris')
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
sns.jointplot(x=df["sepal_length"], y=df["sepal_width"], kind='kde', color="grey", space=3)
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
df = sns.load_dataset('iris')
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
sns.jointplot(x=df["sepal_length"], y=df["sepal_width"], kind='kde',ratio=1)
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
import numpy as np
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
x = np.random.normal(size=50000)
y = x * 3 + np.random.normal(size=50000)
plt.hist2d(x, y, bins=(50, 50), cmap=plt.cm.jet)
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
import numpy as np
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
x = np.random.normal(size=50000)
y = x * 3 + np.random.normal(size=50000)
plt.hist2d(x, y, bins=(300, 300), cmap=plt.cm.jet)
plt.gca()
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
import numpy as np
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
x = np.random.normal(size=50000)
y = x * 3 + np.random.normal(size=50000)
plt.hist2d(x, y, bins=(300, 30), cmap=plt.cm.jet)
plt.gca()
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
import numpy as np
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
x = np.random.normal(size=50000)
y = x * 3 + np.random.normal(size=50000)
plt.hist2d(x, y, bins=(50, 50), cmap=plt.cm.Reds)
plt.gca()
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
import numpy as np
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
x = np.random.normal(size=50000)
y = x * 3 + np.random.normal(size=50000)
plt.hist2d(x, y, bins=(50, 50), cmap=plt.cm.BuPu)
plt.gca()
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
import numpy as np
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
x = np.random.normal(size=50000)
y = x * 3 + np.random.normal(size=50000)
plt.hist2d(x, y, bins=(50, 50), cmap=plt.cm.Greys)
plt.gca()
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
import numpy as np
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
x = np.random.normal(size=50000)
y = (x * 3 + np.random.normal(size=50000)) * 5
plt.hexbin(x, y, gridsize=(15,15) )
plt.gca()
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
import numpy as np
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
x = np.random.normal(size=50000)
y = (x * 3 + np.random.normal(size=50000)) * 5
plt.hexbin(x, y, gridsize=(150,150) )
plt.gca()
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
import numpy as np
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
x = np.random.normal(size=50000)
y = (x * 3 + np.random.normal(size=50000)) * 5
plt.hexbin(x, y, gridsize=(25,25), cmap=plt.cm.Greens)
plt.gca()
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
import numpy as np
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
x = np.random.normal(size=50000)
y = (x * 3 + np.random.normal(size=50000)) * 5
plt.hexbin(x, y, gridsize=(25,25), cmap=plt.cm.BuGn_r)
plt.gca()
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
import numpy as np
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
x = np.random.normal(size=50000)
y = (x * 3 + np.random.normal(size=50000)) * 5
plt.hexbin(x, y, gridsize=(25,25), cmap=plt.cm.Purples_r)
plt.colorbar()
plt.show()
本博主新开公众号, 希望大家能扫码关注一下,十分感谢大家。
本文来自:https://github.com/holtzy/The-Python-Graph-Gallery/blob/master/PGG_notebook.py
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
已为社区贡献6条内容
所有评论(0)