Repository: SciTools/cartopy

Issue:
coastlines drawn under filled contours
When using matplotlib v1.3.x and cartopy v0.7.x (development master from github) coastlines and other features are drawn underneath filled contours unless:

```
ax.coastlines(zorder=1)
```

is used to manually raise them above. I suspect this may be a matplotlib issue, but thought it would be best to raise it here for the cartopy experts to take a look at first.



Discussion:
Thanks @ajdawson - something changed between v1.2.0 and v1.3.x which I didn't spot as it went by. I'm minded to fix this at the mpl end once and for all, but that will certainly involve a MEP and a fair bit of time. Did the call order make any difference (i.e. did calling coastlines before vs after make any difference?).

@pelson No the call order makes no difference. Do you know roughly what the problem is in MPL?

> Do you know roughly what the problem is in MPL?

Not specifically. The MEP I would propose would remove the grouping of zordered items which currently occurs. For example:

```
ax.add_collection(c1_zorder_1)
ax.add_patch(p1_zorder_1)
ax.add_collection(c2_zorder_1)
```

Would currently see `c1` and `c2` drawn before `p1` because of the `axes.draw` method implementation.

That behaviour isn't new between v1.2.x and v1.3.x though. I'd need to do a `git bisect` to find out the specifics in this case.

I think I've figured out the specific bug in this case. The class attribute `matplotlib.collections.PathCollection.zorder` is used in `cartopy.mpl.feature_artist.FeatureArtist` to set the zorder. This used to be a class atrribute of `PathCollection` with the value `2`. This (overridden) class attribute was removed in https://github.com/matplotlib/matplotlib/commit/b3dafb9abca9d5d589930802cdf9e582970cf2d1, so instead `cartopy.mpl.feature_artist.FeatureArtist` sees the  value of `matplotlib.collections.PathCollection.zorder` that was inherited from `matplotlib.artist.Artist` which has the value `0`. Does that make sense?

Anyway, I'm not sure what course of action is best. You could:

a) change the value in `cartopy.mpl.feature_artist.FeatureArtist` to `2` (hard coded)
b) add the overridden class atrribute back in mpl (probably not going to happen)
c) some other solution I haven't thought of

If option (a) is desirable I'd be happy to do a PR for it.

> Does that make sense?

Seems so. I think it's could be a tricky issue to solve first time, but provided the use can override, defaulting the zorder to 2 seems fine to me. If you're happy to put a PR in in the next day or so, I'd base it against `v0.6.x` and we can get it in the release this week.

Cheers for looking at this @ajdawson 


Resolving patch:
diff --git a/lib/cartopy/mpl/feature_artist.py b/lib/cartopy/mpl/feature_artist.py
--- a/lib/cartopy/mpl/feature_artist.py
+++ b/lib/cartopy/mpl/feature_artist.py
@@ -75,7 +75,10 @@ def __init__(self, feature, **kwargs):
         elif feature.kwargs.get('zorder') is not None:
             self.set_zorder(feature.kwargs['zorder'])
         else:
-            self.set_zorder(matplotlib.collections.PathCollection.zorder)
+            # The class attribute matplotlib.collections.PathCollection.zorder
+            # was removed after mpl v1.2.0, so the hard-coded value of 1 is
+            # used instead.
+            self.set_zorder(1)
 
         self._feature = feature
 


Test patch: