将多个地块附加到 seaborn 地块
Attaching multiple plots to a seaborn plot
以下代码:
import seaborn as sns
sns.lmplot(x='EstCurentMarketValueSqFt',
y='MarketValueSqFt',
data=sales,
scatter_kws={'edgecolor': "black",
'linewidth': 1})
生成如下图片:
但是,我想另外绘制一对对应于散点的上下边界的线。为此,我需要在现有图的顶部绘制这些线。
最好的方法是什么?
sns.lmplot
不会立即与 matplotlib
方法交互(至少,不是我习惯的方式),因为它附加到 sns.FacetGrid
.
再阅读 API 之后,建议使用 regplot
。这行得通:
f, ax = plt.subplots(figsize=(12, 12))
ax.set_xlim([0, 5000])
ax.set_ylim([0, 5000])
sns.regplot(x='EstCurentMarketValueSqFt',
y='MarketValueSqFt',
data=sales,
scatter_kws={'edgecolor': "white",
'linewidth': 1},
)
plt.plot([1, 5000], [1, 500])
plt.plot([1, 500], [1, 5000])
给出:
以下代码:
import seaborn as sns
sns.lmplot(x='EstCurentMarketValueSqFt',
y='MarketValueSqFt',
data=sales,
scatter_kws={'edgecolor': "black",
'linewidth': 1})
生成如下图片:
但是,我想另外绘制一对对应于散点的上下边界的线。为此,我需要在现有图的顶部绘制这些线。
最好的方法是什么?
sns.lmplot
不会立即与 matplotlib
方法交互(至少,不是我习惯的方式),因为它附加到 sns.FacetGrid
.
再阅读 API 之后,建议使用 regplot
。这行得通:
f, ax = plt.subplots(figsize=(12, 12))
ax.set_xlim([0, 5000])
ax.set_ylim([0, 5000])
sns.regplot(x='EstCurentMarketValueSqFt',
y='MarketValueSqFt',
data=sales,
scatter_kws={'edgecolor': "white",
'linewidth': 1},
)
plt.plot([1, 5000], [1, 500])
plt.plot([1, 500], [1, 5000])
给出: