将多个地块附加到seaborn地块

时间:2016-06-18 18:44:11

标签: python matplotlib data-visualization seaborn

以下代码:

import seaborn as sns
sns.lmplot(x='EstCurentMarketValueSqFt',
           y='MarketValueSqFt',
           data=sales,
           scatter_kws={'edgecolor': "black",
                        'linewidth': 1})

生成以下图片:

Building libcurl with SSL support on Windows

但是,我想另外绘制一对与散射的上下界对应的线。要做到这一点,我需要在这个现有的情节之上绘制这些线。

最好的方法是什么?

1 个答案:

答案 0 :(得分:0)

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])

给出:

enter image description here