Hello, thanks for the response. This is how I did this.

You can easily access maps at https://www.openstreetmap.org/. There you can give the boundaries and take a screenshot or download the region in the world as a png/jpeg.

After that, you can simply overlay your points on the map. To make perfect overlap with cities, we mark the extends on the plot. This is the code;

region = [dataset["long"].min(), dataset["long"].max(), dataset["lat"].min(), dataset["lat"].max()]


ax = dataset.plot(kind="scatter", x="long", y="lat", figsize=(18,8),
s=dataset['sqft_living']/200, label="Living Area",
c="price", cmap=plt.get_cmap("jet"),
colorbar=False, alpha=0.5,
plt.imshow(seattle_img, extent=region, alpha=1, cmap=plt.get_cmap("jet"))
plt.ylabel("Latitude", fontsize=14)
plt.xlabel("Longitude", fontsize=14)

prices = dataset["price"]
tick_values = np.linspace(prices.min(), prices.max(), 11)
cbar = plt.colorbar()
cbar.ax.set_yticklabels(["$%dk"%(round(v)/1000) for v in tick_values], fontsize=14)
cbar.set_label('Price', fontsize=16)


However, I have attached the jupyter notebook for the entire analysis.

Let me know if this helps. :)


Written by

Blogger | Traveler | Programmer PhD Scholar

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store