4

The usual. My shapefile is from a much bigger place than my data, and I want to zoom in. The dark dot below is Melbourne, and it has some very interesting data plotted on it.

enter image description here

base.plot(linewidth=0
     ,color='gray'
     ,alpha=.1
     ,ax=ax)
2

I had forgotten to use the cartopy projection, which sets the .set_extent property in the matplotlib axis.

import cartopy.crs as ccrs

extent = (b['x coordinate'].min(), b['x coordinate'].max(), b['y coordinate'].min(), b['y coordinate'].max())

ax = plt.axes([0, 0, 1, 1],
                projection=ccrs.LambertCylindrical())
ax.set_extent(extent, ccrs.LambertCylindrical())

cols = ['x coordinate','y coordinate', 'div_name','div_code']
dd = d[cols]
dd.columns = ['long','lat', 'div_name','div_code']
educ = dd.loc[dd.div_code == 'P']
retail = dd.loc[dd.div_code == 'G']
ax = sns.kdeplot(educ.long, educ.lat,
                cmap="Reds", n_levels=5, shade=False, shade_lowest=False, plot_kws={'alpha':0.3}, ax=ax)
sns.kdeplot(retail.long, retail.lat,
                cmap="Blues", n_levels=5, shade=False, shade_lowest=False, plot_kws={'alpha':0.3}, ax=ax)

base.plot(linewidth=0
        ,color='gray'
        ,alpha=.1
        ,ax=ax)

enter image description here

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.