Skip to content

Commit 0618d31

Browse files
author
Patrick Marsh
committed
ENH: Color-filled Counties
Added a keyword argument to allow for color filling counties. Achieved by conververting LineCollection to PolyCollection
1 parent ba8819f commit 0618d31

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/mpl_toolkits/basemap/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
(_mpl_required_version,_matplotlib_version))
2424
raise ImportError(msg)
2525
from matplotlib import rcParams, is_interactive
26-
from matplotlib.collections import LineCollection
26+
from matplotlib.collections import LineCollection, PolyCollection
2727
from matplotlib.patches import Ellipse, Circle, Polygon, FancyArrowPatch
2828
from matplotlib.lines import Line2D
2929
from matplotlib.transforms import Bbox
@@ -1956,7 +1956,7 @@ def drawstates(self,linewidth=0.5,linestyle='solid',color='k',antialiased=1,ax=N
19561956
return states
19571957

19581958
def drawcounties(self,linewidth=0.1,linestyle='solid',color='k',antialiased=1,
1959-
ax=None,zorder=None,drawbounds=False):
1959+
facecolor='none',ax=None,zorder=None,drawbounds=False):
19601960
"""
19611961
Draw county boundaries in US. The county boundary shapefile
19621962
originates with the NOAA Coastal Geospatial Data Project
@@ -1970,6 +1970,7 @@ def drawcounties(self,linewidth=0.1,linestyle='solid',color='k',antialiased=1,
19701970
linewidth county boundary line width (default 0.1)
19711971
linestyle coastline linestyle (default solid)
19721972
color county boundary line color (default black)
1973+
facecolor fill color of county (default is no fill)
19731974
antialiased antialiasing switch for county boundaries
19741975
(default True).
19751976
ax axes instance (overrides default axes instance)
@@ -1985,10 +1986,11 @@ def drawcounties(self,linewidth=0.1,linestyle='solid',color='k',antialiased=1,
19851986
county_info = self.readshapefile(gis_file,'counties',\
19861987
default_encoding='latin-1',drawbounds=drawbounds)
19871988
counties = [coords for coords in self.counties]
1988-
counties = LineCollection(counties)
1989+
counties = PolyCollection(counties)
19891990
counties.set_linestyle(linestyle)
19901991
counties.set_linewidth(linewidth)
1991-
counties.set_color(color)
1992+
counties.set_edgecolor(color)
1993+
counties.set_facecolor(facecolor)
19921994
counties.set_label('counties')
19931995
if zorder:
19941996
counties.set_zorder(zorder)

0 commit comments

Comments
 (0)