Python seaborn子地块
如何创建一个包含2个seaborn地块(子地块)的地块 如何将2个seaborn地块合并为1个Python seaborn子地块,python,seaborn,Python,Seaborn,如何创建一个包含2个seaborn地块(子地块)的地块 如何将2个seaborn地块合并为1个 plt.figure(figsize = (12, 6)) ax = sns.scatterplot(x = model1.fittedvalues, y = model1.resid) plt.grid() ax.axhline(y=0, color='r', linewidth=4) ax.set_xlabel("vysvětlovaná proměnná"); ax.set_ylabel("r
plt.figure(figsize = (12, 6))
ax = sns.scatterplot(x = model1.fittedvalues, y = model1.resid)
plt.grid()
ax.axhline(y=0, color='r', linewidth=4)
ax.set_xlabel("vysvětlovaná proměnná");
ax.set_ylabel("residua");
plt.figure(figsize = (12, 6))
ax = sns.distplot(a = model1.resid, bins = 40, norm_hist=True,)
plt.grid()
ax.set_title("Histogram reziduí", fontsize = 25);
您可以随意创建子地块(使用
plt.subplot()
,fig.add_subplot()
,GridSpec
,您可以命名),然后使用ax=
将轴引用传递给seaborn函数
您可以更好地定义子地块:
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
x = np.array([4,3,2,3])
y = np.array([5,1,6,4])
**fig, sub = plt.subplots(2,1)**
plt.figure(figsize = (12, 6))
sns.scatterplot(x, y , **ax=sub[0]**)
ax.axhline(y=0, color='r', linewidth=4)
ax.set_xlabel("vysvětlovaná proměnná")
ax.set_ylabel("residua")
plt.figure(figsize = (12, 6))
sns.distplot(x, bins = 40, norm_hist=True, **ax=sub[1]**)
ax.set_title("Histogram reziduí", fontsize = 25)
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
x = np.array([4,3,2,3])
y = np.array([5,1,6,4])
**fig, sub = plt.subplots(2,1)**
plt.figure(figsize = (12, 6))
sns.scatterplot(x, y , **ax=sub[0]**)
ax.axhline(y=0, color='r', linewidth=4)
ax.set_xlabel("vysvětlovaná proměnná")
ax.set_ylabel("residua")
plt.figure(figsize = (12, 6))
sns.distplot(x, bins = 40, norm_hist=True, **ax=sub[1]**)
ax.set_title("Histogram reziduí", fontsize = 25)