From 4fd043cb767024cfc37d8522cc297f67e8d3b014 Mon Sep 17 00:00:00 2001 From: Benjamin Root Date: Thu, 2 Feb 2017 14:30:44 -0500 Subject: [PATCH] Use the default zorder of LineCollections for county polycollections. Closes #324. --- lib/mpl_toolkits/basemap/__init__.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/mpl_toolkits/basemap/__init__.py b/lib/mpl_toolkits/basemap/__init__.py index 10fb6d0ce..e30091f3c 100644 --- a/lib/mpl_toolkits/basemap/__init__.py +++ b/lib/mpl_toolkits/basemap/__init__.py @@ -1960,23 +1960,32 @@ def drawcounties(self,linewidth=0.1,linestyle='solid',color='k',antialiased=1, ax axes instance (overrides default axes instance) zorder sets the zorder for the county boundaries (if not specified, uses default zorder for - matplotlib.patches.LineCollections). + `matplotlib.patches.LineCollections`). ============== ==================================================== - returns a matplotlib.patches.LineCollection object. + returns a matplotlib.collections.PolyCollection object. + + .. note:: + Returning a `PolyCollection` for this method deviates from + other functions like :func:`drawstates` which return + `LineCollection` objects. However, to ensure that counties + will typically appear in front, the default zorder of + `LineCollection` is used as the default here. + """ ax = ax or self._check_ax() gis_file = os.path.join(basemap_datadir,'UScounties') county_info = self.readshapefile(gis_file,'counties',\ default_encoding='latin-1',drawbounds=drawbounds) counties = [coords for coords in self.counties] - counties = PolyCollection(counties) + # Hard-coding a default zorder to keep counties in front + counties = PolyCollection(counties, zorder=2) counties.set_linestyle(linestyle) counties.set_linewidth(linewidth) counties.set_edgecolor(color) counties.set_facecolor(facecolor) counties.set_label('counties') - if zorder: + if zorder is not None: counties.set_zorder(zorder) ax.add_collection(counties) return counties