Skip to content

Commit e353bf2

Browse files
author
Jeff Whitaker
committed
Merge pull request #127 from pmarshwx/draw_counties
ENH: Color-filled Counties
2 parents 0c9fc20 + 6b8ca42 commit e353bf2

File tree

2 files changed

+44
-37
lines changed

2 files changed

+44
-37
lines changed

Changelog

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
version 1.0.8 (not yet released)
2+
--------------------------------
3+
* added 'facecolor' keyward argument to drawcounties() method; gives user
4+
ability to fill counties with specified matplotlib color argument.
5+
16
version 1.0.7 (git tag v1.0.7rel)
27
---------------------------------
38
* include mpl_toolkits/__init__.py, since the one installed by matplotlib
@@ -19,7 +24,7 @@ version 1.0.6 (git tag v1.0.6rel)
1924
* update pyproj to version 1.9.3 (remove geographiclib python code, replace
2025
with C code from proj4).
2126
* in contourf and contour, all points outside the map projection
22-
region were masked. This meant that if a grid cell was partly inside and partly
27+
region were masked. This meant that if a grid cell was partly inside and partly
2328
outside the map projection region, nothing was drawn, leaving a gap along the
2429
edge of the map. This was particularly noticeable for very coarse resolution grids.
2530
This commit only masks those points more than one grid length beyond the edge
@@ -31,8 +36,8 @@ version 1.0.6 (git tag v1.0.6rel)
3136
(requires using 'epsg' keyword to define projection).
3237
* fix drawing of meridians and parallels for very small map regions
3338
(issue 79).
34-
* add module variable 'latlon_default' that can be used to switch
35-
default value of latlon kwarg to True so plotting methods can be
39+
* add module variable 'latlon_default' that can be used to switch
40+
default value of latlon kwarg to True so plotting methods can be
3641
passed lats and lons (geographic coordinatsin degrees) instead
3742
of x,y (projection coordinates).
3843
* have drawcoastlines use line segments instead of coastline polygons, to
@@ -48,7 +53,7 @@ version 1.0.6 (git tag v1.0.6rel)
4853
* added linestyle keyword to all draw* methods.
4954
* added 'drawcounties' method (https://github.com/matplotlib/basemap/pull/65)
5055
thanks to Patrick Marsh.
51-
* fix bug that caused plotting to fail when latlon keyword is
56+
* fix bug that caused plotting to fail when latlon keyword is
5257
explicitly set to False (https://github.com/matplotlib/basemap/pull/66).
5358
* add latlon keyword to plot and scatter methods
5459
(https://github.com/matplotlib/basemap/pull/64).
@@ -69,7 +74,7 @@ version 1.0.5 (git tag v1.0.5rel)
6974
to illustrate usage.
7075
* fix bluemarble and warpimage methods to account for change in orientation
7176
of arrays returned to matplotlib's pil_to_array (issue 51)
72-
* fix glitch with drawing meridians and filling coastline polygons with
77+
* fix glitch with drawing meridians and filling coastline polygons with
7378
omerc projection that includes pole.
7479

7580
version 1.0.4 (git tag v1.0.4rel)
@@ -97,10 +102,10 @@ version 1.0.3 (git tag v1.0.3rel)
97102
* update coastlines, rivers, political boundaries to GSHHS
98103
2.2.0/GMT 4.5.7. The fillcontinents bug (filling the outside
99104
instead of the inside of a coastline polygon) is now much
100-
harder to trigger.
105+
harder to trigger.
101106
* add 'round' keyword keyword to Basemap.__init__ for pole-centered
102107
projections to make them round (clipped at boundinglat) instead
103-
of square.
108+
of square.
104109
* added hexbin method, along with hexbin_demo.py example.
105110
* drawmapboundary now uses axes bgcolor as default fill_color. If
106111
no color fill wanted, set fill_color='none' (a string).
@@ -141,7 +146,7 @@ version 1.0.2 (git tag v1.0.2)
141146
* change default land-sea mask (now derived directly from gshhs
142147
coastline data, default is 5 minutes use coastline resolution =
143148
'l'). Default for plotting lakes is now True.
144-
* add etopo method (similar to bluemarble, but plots etopo
149+
* add etopo method (similar to bluemarble, but plots etopo
145150
relief image from www.ngdc.noaa.gov/mgg/global as a map background).
146151
* add shadedrelief method (similar to bluemarble, but plots shaded
147152
relief image from naturalearthdata.com as a map background).
@@ -169,7 +174,7 @@ version 1.0.1 (svn revision 8967)
169174
projection to proj4 src in src/PJ_hammer.c).
170175
* updated src/pj_mutex.c from proj4 svn to fix a threading bug
171176
on Windows.
172-
* if you try to transform NaNs to/from map projection coords, 1.e30
177+
* if you try to transform NaNs to/from map projection coords, 1.e30
173178
is returned (previously, this caused a segfault for some
174179
projections).
175180
* NetCDFFile function deprecated, will be removed in 1.0.2. Issue
@@ -207,15 +212,15 @@ version 1.0 (svn revision 8531)
207212
'daynight.py' example added to illustrate usage.
208213
* added lonmin, lonmax instance variables.
209214
version 0.99.4 (svn revision 7332)
210-
* ax.frame replaced with ax.spines to maintain compatibility
215+
* ax.frame replaced with ax.spines to maintain compatibility
211216
with matplotlib spines support.
212-
* added latmax kwarg to drawparallels and drawmeridians
217+
* added latmax kwarg to drawparallels and drawmeridians
213218
(patch from Chris Murphy).
214219
* added new example "plotmap_shaded.py" (shaded relief plot).
215220
* added new example "plothighsandlows.py".
216221
* add fix_aspect kwarg to Basemap.__init__, when False
217222
axes.set_aspect is set to 'auto' instead of default 'equal'.
218-
Can be used to make plot fill whole plot region, even if the
223+
Can be used to make plot fill whole plot region, even if the
219224
plot region doesn't match the aspect ratio of the map region.
220225
* added date2index function, updated netcdftime to 0.7.1.
221226
* added maskoceans function.
@@ -224,20 +229,20 @@ version 0.99.4 (svn revision 7332)
224229
one of the shapefile components can't be found.
225230
version 0.99.3 (svn revision 6780)
226231
* if upper right/lower left corners nor width/height given for
227-
azimuthal equidistant ('aeqd') the whole world is drawn in
232+
azimuthal equidistant ('aeqd') the whole world is drawn in
228233
a circle (only works for perfect spheres, not ellipsoids).
229234
* have setup.py check for already installed pyshapelib (just
230235
like it does for httplib2 and pydap).
231236
* Basemap will now look for it's data in BASEMAPDATA.
232-
If that env var not set, it will fall back to it's
237+
If that env var not set, it will fall back to it's
233238
default location.
234239
* if readshapefile is called with drawbounds=True, a
235240
LineCollection object is appended to the returned tuple.
236241
* make sure drawmapscale method returns a list of objects that
237242
can be iterated over to remove them from the plot.
238243
* fillcontinents was returning just last Polygon instance.
239-
Now returns a list of all Polygon instances.
240-
* bluemarble/warpimage: pass kwargs to imshow,
244+
Now returns a list of all Polygon instances.
245+
* bluemarble/warpimage: pass kwargs to imshow,
241246
return Image instance.
242247
version 0.99.2 (svn revision 6541)
243248
* fix drawlsmask method so that it works for cylindrical
@@ -269,7 +274,7 @@ version 0.99.2 (svn revision 6541)
269274
* added "proj4string" Basemap instance variable.
270275
* testgdal example now uses gdal to read topo data from a raster
271276
DEM file and ogr to read state boundaries from a shape file.
272-
* warpimage method can now handle gray-scale images, and
277+
* warpimage method can now handle gray-scale images, and
273278
images specifed as URLs (for example, the Blue Marble images from
274279
http://earthobservatory.nasa.gov/Newsroom/BlueMarble/BlueMarble_monthlies.html).
275280
version 0.99.1 (svn revision 5961)
@@ -295,7 +300,7 @@ version 0.99 (svn revision 5344)
295300
* drawcoastlines, drawcountries and friends now have
296301
PatchCollection return values.
297302
* make sure '_nolabel_' set on coastlines, countries, states,
298-
rivers, parallels and meridians so they are not included in
303+
rivers, parallels and meridians so they are not included in
299304
a legend.
300305
* added drawmapscale method to create a map scale bar similar
301306
to that available with the GMT's psbasemap.
@@ -332,7 +337,7 @@ version 0.9.9 (svn revision 4799)
332337
* now automatically draws figure if running in
333338
interactive mode (so draw() does not need
334339
to be called explicitly in ipython).
335-
* added num2date and date2num functions, which use
340+
* added num2date and date2num functions, which use
336341
included netcdftime module.
337342
version 0.9.8 (svn revision 4526)
338343
* fixes for filling continents in orthographic projection.
@@ -341,12 +346,12 @@ version 0.9.8 (svn revision 4526)
341346
of variable data.
342347
* NetCDFFile will try to use PyNIO if it installed
343348
and the file cannot be read with pupynere. This
344-
allows GRIB1,GRIB2,HDF4 and HDFEOS2 files to
349+
allows GRIB1,GRIB2,HDF4 and HDFEOS2 files to
345350
be read.
346-
* 'fmt' kwarg to drawparallels and drawmeridians can
351+
* 'fmt' kwarg to drawparallels and drawmeridians can
347352
now be a custom string formatting function (example
348353
customticks.py demonstrates usage).
349-
* remove 'linestyle' kwarg from drawparallels and
354+
* remove 'linestyle' kwarg from drawparallels and
350355
drawmeridians (it never did anything anyway since
351356
it was overridden by the 'dashes' kwarg).
352357
* modify NetCDFFile to use dap module to read remote
@@ -363,7 +368,7 @@ version 0.9.7 (svn revision 4422)
363368
projections.
364369
* added lake_color keyword to fillcontinents.
365370
* fixed a bug in the 'tmerc' projection.
366-
* added pure python NetCDFFile reader from Roberto De Almeida
371+
* added pure python NetCDFFile reader from Roberto De Almeida
367372
to basemap namespace
368373
(from matplotlib.toolkits.basemap import NetCDFFile).
369374
* added support for full-resolution boundaries (will be
@@ -392,11 +397,11 @@ version 0.9.6 (svn revision 3888)
392397
llcrnrlon,urcrnrlat,urcrnrlon keywords for 'ortho' and 'geos'.
393398
(illustrated by examples/geos_demo_2.py).
394399
* Added "labelstyle" keyword to drawparallels and drawmeridians.
395-
If set to "+/-", labels are given prefixed by "+" or "-",
396-
instead of suffixed with "N","S","E" or "W". Useful for
400+
If set to "+/-", labels are given prefixed by "+" or "-",
401+
instead of suffixed with "N","S","E" or "W". Useful for
397402
astronomical plots, where the is no such thing and north, south
398403
east or west.
399-
* Added support for geostationary satellite projection
404+
* Added support for geostationary satellite projection
400405
(projection='geos'), contributed by Scott Sinclair.
401406
Illustrated by examples/geos_demo.py.
402407
* added a bunch of extra colormaps (mostly from GMT),
@@ -405,7 +410,7 @@ version 0.9.6 (svn revision 3888)
405410
import cm'
406411
* orthographic projection only defined for perfect sphere - raise
407412
an error if user tries to use an ellipsoid.
408-
* print a warning in contour, contourf in situations that may
413+
* print a warning in contour, contourf in situations that may
409414
result in a screwy looking plot (x not monotonically increasing,
410415
because the data wraps around the edge of the plot). The warning
411416
suggests using the shiftgrid function to recenter the data on
@@ -425,7 +430,7 @@ version 0.9.6 (svn revision 3888)
425430
* fixed examples to conform to 'one show() per script' rule.
426431
* intermediate coastlines now installed by default.
427432
basemap-data is no longer a separate package (couldn't
428-
figure out how to manage the egg). If the 'h' res
433+
figure out how to manage the egg). If the 'h' res
429434
boundaries are needed, the data files must be manually
430435
put in place by the user. BASEMAP_DATA_PATH env var
431436
no longer used.
@@ -467,9 +472,9 @@ version 0.9.6 (svn revision 3888)
467472
Now maps will always have the correct aspect ratio.
468473
* if resolution keyword is set to None when Basemap
469474
instance is created, no boundary data sets are needed
470-
(methods to draw boundaries, like drawcoastlines, will
475+
(methods to draw boundaries, like drawcoastlines, will
471476
raise an exception).
472-
* update to proj4 module - renamed pyproj to avoid
477+
* update to proj4 module - renamed pyproj to avoid
473478
conflicts with proj4 module from CDAT.
474479
* createfigure method deprecated, since maps
475480
will now automatically have the correct aspect ratio.
@@ -478,7 +483,7 @@ version 0.9.6 (svn revision 3888)
478483
versions of the stereographic, lambert azimuthal equal area
479484
and azimuthal equidistant projections that don't require
480485
you specify the lat/lon values of the lower-left and upper-right
481-
corners.
486+
corners.
482487
* fixed bugs in plot, scatter and mapboundary methods for
483488
miller, cylindrical and mercator projections.
484489
* 'crude' and 'low' resolution boundary datasets now installed
@@ -499,7 +504,7 @@ version 0.9.6 (svn revision 3888)
499504
20060203: version 0.8.1: Huge speedups for numpy
500505
(no significant differences for Numeric and numarray).
501506
20060114: version 0.8: added numpy compatibility
502-
20051118: version 0.7.2.1:
507+
20051118: version 0.7.2.1:
503508
There was a problem running examples that read pickle files.
504509
The pickle files were created with numarray, and the
505510
data would not be read correctly using Numeric. Fixed so
@@ -512,7 +517,7 @@ version 0.9.6 (svn revision 3888)
512517
by contour and contourf.
513518
* Axes frame turned off by default for non-rectangular
514519
projections ('ortho','robin' and 'moll').
515-
* Added createfigure method to create a figure with the
520+
* Added createfigure method to create a figure with the
516521
same aspect ratio as the map using pylab.figure.
517522
* Resets subplot.params defaults so that default
518523
axes rectangle will have both a width and height of 0.9

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)