Faceted Scatter Plot

Housing Prices by Region

Real estate value drivers across metropolitan areas

Output
Housing Prices by Region
Python
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np

np.random.seed(555)

regions = ['Urban Core', 'Suburban', 'Exurban', 'Rural']
data = []
for region in regions:
    n = 42
    sqft = np.random.uniform(800, 4000, n)
    price_per_sqft = {'Urban Core': 450, 'Suburban': 280, 'Exurban': 180, 'Rural': 120}
    price = price_per_sqft[region] * sqft / 1000 + np.random.normal(0, 50, n)
    for sq, p in zip(sqft, price):
        data.append({'Square Feet': sq, 'Price ($K)': p, 'Region': region})

df = pd.DataFrame(data)

sns.set_style("whitegrid", {
    'axes.facecolor': '#ffffff',
    'figure.facecolor': '#ffffff',
    'grid.color': '#eeeeee'
})

palette = ['#C82909', '#27D3F5', '#6CF527', '#F5D327']

g = sns.lmplot(
    data=df,
    x='Square Feet',
    y='Price ($K)',
    hue='Region',
    col='Region',
    col_wrap=2,
    height=3.5,
    aspect=1.2,
    palette=palette,
    scatter_kws={'alpha': 0.7, 's': 50, 'edgecolor': 'white', 'linewidths': 0.6},
    line_kws={'linewidth': 2.5},
    ci=95
)

g.fig.set_facecolor('#ffffff')
for ax in g.axes.flat:
    ax.set_facecolor('#ffffff')
    for spine in ax.spines.values():
        spine.set_color('#dddddd')

g.fig.suptitle('Home Valuation by Location', fontsize=14, fontweight='bold', color='#1a1a1a', y=1.02)
plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Pairwise Data

Did this help you?

Support PyLucid to keep it free & growing

Support