Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the default zorder of LineCollections for county polycollections. #340

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions lib/mpl_toolkits/basemap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down