Created
June 27, 2017 04:18
-
-
Save QuLogic/747ac39df0ddfe159b49f9e8c792eee6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
from matplotlib.colors import Normalize | |
import numpy as np | |
import cartopy.crs as ccrs | |
import time | |
NROW = NCOL = 1 | |
nlats, nlons = (241, 480) | |
lats = np.linspace(90, -90, nlats) | |
lons = np.linspace(0, 360, nlons) | |
l1, l2 = np.meshgrid(lons, lats) | |
data = l1 + l2 | |
cmap = plt.get_cmap('viridis') | |
norm = Normalize(vmin=0, vmax=data.max()) | |
start_time = time.time() | |
fig, axes = plt.subplots(NROW, NCOL, | |
subplot_kw=dict(projection=ccrs.Robinson(central_longitude=150)), | |
squeeze=False) | |
for ax in axes.flat: | |
coll = ax.pcolormesh(lons, lats, l1 + l2, transform=ccrs.PlateCarree(), | |
cmap=cmap, norm=norm) | |
ax.coastlines() | |
fig.savefig('pcolormesh_cartopy.png') | |
print("pcolormesh cartopy: {:.2f} s".format(time.time() - start_time)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment