Replacing axes by ax to keep consistency, addressing issue #208

This commit is contained in:
Dani Arribas-Bel
2015-10-09 22:41:38 +01:00
parent bdfc7fb819
commit 5d526d288d
+8 -12
View File
@@ -74,7 +74,7 @@ def gencolor(N, colormap='Set1'):
yield colors[i % n_colors]
def plot_series(s, colormap='Set1', axes=None, linewidth=1.0, figsize=None, **color_kwds):
def plot_series(s, colormap='Set1', ax=None, linewidth=1.0, figsize=None, **color_kwds):
""" Plot a GeoSeries
Generate a plot of a GeoSeries geometry with matplotlib.
@@ -95,7 +95,7 @@ def plot_series(s, colormap='Set1', axes=None, linewidth=1.0, figsize=None, **co
Accent, Dark2, Paired, Pastel1, Pastel2, Set1, Set2, Set3
axes : matplotlib.pyplot.Artist (default None)
ax : matplotlib.pyplot.Artist (default None)
axes on which to draw the plot
linewidth : float (default 1.0)
@@ -103,7 +103,7 @@ def plot_series(s, colormap='Set1', axes=None, linewidth=1.0, figsize=None, **co
figsize : pair of floats (default None)
Size of the resulting matplotlib.figure.Figure. If the argument
axes is given explicitly, figsize is ignored.
ax is given explicitly, figsize is ignored.
**color_kwds : dict
Color options to be passed on to plot_polygon
@@ -114,11 +114,9 @@ def plot_series(s, colormap='Set1', axes=None, linewidth=1.0, figsize=None, **co
matplotlib axes instance
"""
import matplotlib.pyplot as plt
if axes is None:
if ax is None:
fig, ax = plt.subplots(figsize=figsize)
ax.set_aspect('equal')
else:
ax = axes
color = gencolor(len(s), colormap=colormap)
for geom in s:
if geom.type == 'Polygon' or geom.type == 'MultiPolygon':
@@ -132,7 +130,7 @@ def plot_series(s, colormap='Set1', axes=None, linewidth=1.0, figsize=None, **co
def plot_dataframe(s, column=None, colormap=None, linewidth=1.0,
categorical=False, legend=False, axes=None,
categorical=False, legend=False, ax=None,
scheme=None, k=5, vmin=None, vmax=None, figsize=None,
**color_kwds
):
@@ -169,7 +167,7 @@ def plot_dataframe(s, column=None, colormap=None, linewidth=1.0,
Plot a legend (Experimental; currently for categorical
plots only)
axes : matplotlib.pyplot.Artist (default None)
ax : matplotlib.pyplot.Artist (default None)
axes on which to draw the plot
scheme : pysal.esda.mapclassify.Map_Classifier
@@ -212,7 +210,7 @@ def plot_dataframe(s, column=None, colormap=None, linewidth=1.0,
from matplotlib import cm
if column is None:
return plot_series(s.geometry, colormap=colormap, axes=axes, linewidth=linewidth, figsize=figsize, **color_kwds)
return plot_series(s.geometry, colormap=colormap, ax=ax, linewidth=linewidth, figsize=figsize, **color_kwds)
else:
if s[column].dtype is np.dtype('O'):
categorical = True
@@ -234,11 +232,9 @@ def plot_dataframe(s, column=None, colormap=None, linewidth=1.0,
categories = ['{0:.2f} - {1:.2f}'.format(binedges[i], binedges[i+1])
for i in range(len(binedges)-1)]
cmap = norm_cmap(values, colormap, Normalize, cm, vmin=vmin, vmax=vmax)
if axes is None:
if ax is None:
fig, ax = plt.subplots(figsize=figsize)
ax.set_aspect('equal')
else:
ax = axes
for geom, value in zip(s.geometry, values):
if geom.type == 'Polygon' or geom.type == 'MultiPolygon':
plot_multipolygon(ax, geom, facecolor=cmap.to_rgba(value), linewidth=linewidth, **color_kwds)