I've been using cartopy to produce multi layered animations of model output, but have hit on an odd issue when using a background image in projections other than PlateCarree; the background image is negated.
A code example is shown below and its output are attached; it downloads an image and plots it using the PlateCarree and Orthographic projections as the image is read in (top row) and after image negation (bottom row).
I can't see a dumb mistake in my code so I presume that something in cartopy needs tweaking?
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import os
from matplotlib.image import imread
import urllib
#retrieve background image to TMPDIR directory
target = os.environ['TMPDIR']+'/world.topo.bathy.200407.3x5400x2700.jpg'
if not os.path.exists(target):
source = 'http://eoimages.gsfc.nasa.gov/images/imagerecords/73000/73751/world.topo.bathy.200407.3x5400x2700.jpg'
print "retrieving image from ", source
urllib.urlretrieve(source, target)
img = imread(target)
img = img[::-1]
fig = plt.figure()
img_neg = 255 - img
for i,p in enumerate([ccrs.PlateCarree(), ccrs.Orthographic()]):
subplt = fig.add_subplot(2,2,i+1, projection=p)
plt.imshow(img, origin='lower', transform=ccrs.PlateCarree(), extent=[-180, 180, -90, 90], zorder=0)
subplt = fig.add_subplot(2,2,i+3, projection=p)
plt.imshow(img_neg, origin='lower', transform=ccrs.PlateCarree(), extent=[-180, 180, -90, 90], zorder=0)
plt.show()