lmplot 是一种集合基础绘图与基于数据建立回归模型的绘图方法。旨在创建一个方便拟合数据集回归模型的绘图方法,利用'hue'、'col'、'row'参数来控制绘图变量。
import matplotlib.pylab as plt
import seaborn as sns
import numpy as np
import pandas as pd
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
x = np.random.rand(80) - 0.5
y = x+np.random.rand(80)
z = x+np.random.rand(80)
df = pd.DataFrame({'x':x, 'y':y, 'z':z})
sns.lmplot( x='x', y='y', data=df, fit_reg=False, hue='x', legend=False, palette="Blues_r")
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
import numpy as np
import pandas as pd
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
x = np.random.rand(80) - 0.5
y = x+np.random.rand(80)
z = x+np.random.rand(80)
df = pd.DataFrame({'x':x, 'y':y, 'z':z})
sns.lmplot( x='x', y='y', data=df, fit_reg=False, hue='x', legend=False, palette="PuOr_r")
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.lmplot( x="sepal_length", y="sepal_width", data=df, fit_reg=False, hue='species', legend=False, palette="Set1")
plt.legend(loc='lower right')
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)
flatui = ["#9b59b6", "#3498db", "orange"]
sns.set_palette(flatui)
sns.lmplot( x="sepal_length", y="sepal_width", data=df, fit_reg=False, hue='species', legend=False)
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
data = sns.load_dataset('iris')
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
plt.subplot(131)
sns.boxplot(data=data)
plt.subplot(132)
sns.violinplot(data=data)
plt.subplot(133)
sns.regplot(x=data["sepal_length"], y=data["sepal_width"])
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
data = sns.load_dataset('iris')
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
plt.subplot(311)
sns.boxplot(data=data)
plt.subplot(312)
sns.violinplot(data=data)
plt.subplot(313)
sns.regplot(x=data["sepal_length"], y=data["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.lmplot( x="sepal_length", y="sepal_width", data=df, fit_reg=False, hue='species', col='species')
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
df = sns.load_dataset('iris')
sns.lmplot( x="sepal_length", y="sepal_width", data=df, fit_reg=False, hue='species', row='species')
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
import numpy as np
data = np.random.normal(size=(20, 6)) + np.arange(6) / 2
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
sns.set_style("whitegrid")
sns.boxplot(data=data)
plt.title("whitegrid")
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
import numpy as np
data = np.random.normal(size=(20, 6)) + np.arange(6) / 2
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
sns.set_style("darkgrid")
sns.boxplot(data=data);
plt.title("darkgrid")
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
import numpy as np
data = np.random.normal(size=(20, 6)) + np.arange(6) / 2
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
sns.set_style("white")
sns.boxplot(data=data);
plt.title("white")
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
import numpy as np
data = np.random.normal(size=(20, 6)) + np.arange(6) / 2
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
sns.set_style("dark")
sns.boxplot(data=data);
plt.title("dark")
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
import numpy as np
data = np.random.normal(size=(20, 6)) + np.arange(6) / 2
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
sns.set_style("ticks")
sns.boxplot(data=data);
plt.title("ticks")
plt.show()
import matplotlib.pylab as plt
import seaborn as sns
import numpy as np
df = sns.load_dataset('iris')
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
sns.lmplot( x="sepal_length", y="sepal_width", data=df, fit_reg=False, hue='species', legend=False, palette="Set1")
plt.legend(loc='lower right', ncol=3)
plt.show()