-
-
Save pwolfram/d1c3f1bf513caf24ce6d3a3a0362ea6c to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env python | |
import matplotlib.pyplot as plt | |
import cartopy.crs | |
import cartopy.feature | |
import shapely | |
for bounds in [[-180,-60,180,60],[-180,-90,180,-60],[-180,-89,180,-60]]: | |
plt.figure() | |
shape = shapely.geometry.box(*bounds) | |
projection = cartopy.crs.Mollweide() | |
ax = plt.axes(projection=projection) | |
resolution = '50m' | |
ax.add_feature(cartopy.feature.NaturalEarthFeature('physical', 'land', resolution, | |
edgecolor='face', facecolor=cartopy.feature.COLORS['land']), zorder=1) | |
ax.add_feature(cartopy.feature.NaturalEarthFeature('physical', 'coastline', resolution, | |
edgecolor='black', facecolor='none'), zorder=2) | |
draw_labels = False | |
ax.gridlines(crs=cartopy.crs.PlateCarree(), draw_labels=draw_labels, | |
linewidth=0.5, color='gray', linestyle='--') | |
if not draw_labels: | |
plt.tight_layout() | |
# use colorbrewer qualitative 7 data class colors, "7-class Accent": http://colorbrewer2.org/ | |
colors = ['#7fc97f' ,'#beaed4', '#fdc086', '#ffff99','#386cb0','#f0027f','#bf5b17'] | |
markers = ['o', 's', 'v', '^', '>', '<', '*', 'p', 'D', 'h'] | |
feature_num = 0 | |
refProjection = cartopy.crs.PlateCarree() | |
color = colors[feature_num % len(colors)] | |
marker = markers[feature_num % len(markers)] | |
props = {'linewidth':2.0, 'edgecolor':color} | |
props['alpha'] = 0.4 | |
props['facecolor'] = color | |
ax.add_geometries((shape,), crs=refProjection, **props) | |
ax.set_global() | |
plt.show() | |
# vim: foldmethod=marker ai ts=4 sts=4 et sw=4 ft=python |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment