Skip to content

Instantly share code, notes, and snippets.

@Dapid
Created March 19, 2020 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dapid/79c152854c1c35e28332214c0ff65477 to your computer and use it in GitHub Desktop.
Save Dapid/79c152854c1c35e28332214c0ff65477 to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.feature as cfeature
lon = 10 + 15 * np.random.random(30)
lat = 55 + 15 * np.random.random(30)
data = np.random.randn(30)
land_10m = cfeature.NaturalEarthFeature('physical', 'land', '10m',
edgecolor='k', facecolor='none')
borders_10m = cfeature.NaturalEarthFeature('cultural', 'admin_0_boundary_lines_land',
'10m', edgecolor='grey', facecolor='none')
subborders_10m = cfeature.NaturalEarthFeature('cultural', 'admin_1_states_provinces',
'10m', edgecolor='grey', alpha=0.3, facecolor='none')
projection = ccrs.TransverseMercator(central_longitude=15, scale_factor=0.9996) #SWEREF89
plate = ccrs.PlateCarree()
fig, ax = plt.subplots(1, 1, constrained_layout=True,
subplot_kw=dict(projection=projection),
figsize=(4, 8))
ax.add_feature(land_10m)
ax.add_feature(borders_10m)
ax.add_feature(subborders_10m)
c = ax.scatter(lon, lat, c=data, transform=plate,
s=5, vmin=-2.5, vmax=2.5, cmap='bwr')
ax.set_title('Data')
plt.colorbar(c, ax=ax)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment