Hello,
I'm trying to do something very simple:
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
ax = plt.axes(projection = ccrs.Geodetic())
Yet:
TypeError Traceback (most recent call last)
<ipython-input-4-465130cc1897> in <module>()
----> 1 ax = plt.axes(projection = ccrs.Geodetic())
C:\Users\Ivan\Anaconda2\lib\site-packages\matplotlib\pyplot.pyc in axes(*args, **kwargs)
865 nargs = len(args)
866 if len(args) == 0:
--> 867 return subplot(111, **kwargs)
868 if nargs > 1:
869 raise TypeError('Only one non keyword arg to axes allowed')
C:\Users\Ivan\Anaconda2\lib\site-packages\matplotlib\pyplot.pyc in subplot(*args, **kwargs)
1020
1021 fig = gcf()
-> 1022 a = fig.add_subplot(*args, **kwargs)
1023 bbox = a.bbox
1024 byebye = []
C:\Users\Ivan\Anaconda2\lib\site-packages\matplotlib\figure.pyc in add_subplot(self, *args, **kwargs)
985 else:
986 projection_class, kwargs, key = process_projection_requirements(
--> 987 self, *args, **kwargs)
988
989 # try to find the axes with this key in the stack
C:\Users\Ivan\Anaconda2\lib\site-packages\matplotlib\projections\__init__.pyc in process_projection_requirements(figure, *args, **kwargs)
102 else:
103 raise TypeError('projection must be a string, None or implement a '
--> 104 '_as_mpl_axes method. Got %r' % projection)
105
106 # Make the key without projection kwargs, this is used as a unique
TypeError: projection must be a string, None or implement a _as_mpl_axes method. Got <cartopy._crs.Geodetic object at 0x000000000625D410>
The same type of error happens for projections Geocentric, Globe and LinearRing, from the ones I tried, if that is of any help? Most others (PlateCarree, Mercator, Robinson etc.) work fine. However, I specifically need Geodetic.
What I'm trying to do is I have data that is on a rotated pole grid (EURO-CORDEX data) and I want to subset a region defined by regular lat-lon coordinates. I used
this question to convert my regular lat-lon bounding box edges to my data's coordinate system and what I want to now do is mask out the data in the bounding box and plot the result, so I can see if the location I've subset is the one I actually want.
I can't see what I'm doing wrong here?
Cheers
Ivan