4
4
import matplotlib .pyplot as plt
5
5
from warnings import warn
6
6
from .tile import howmany , bounds2raster , bounds2img , _sm2ll , _calculate_zoom
7
- from .plotting import ATTRIBUTION , INTERPOLATION , ZOOM
7
+ from .plotting import ATTRIBUTION , INTERPOLATION , ZOOM , add_attribution
8
8
9
9
class Place (object ):
10
10
"""Geocode a place by name and get its map.
@@ -104,7 +104,7 @@ def _get_map(self):
104
104
return im , bbox
105
105
106
106
def plot (self , ax = None , zoom = ZOOM , interpolation = INTERPOLATION ,
107
- attribution_text = ATTRIBUTION ):
107
+ attribution = ATTRIBUTION ):
108
108
"""
109
109
Plot a `Place` object
110
110
...
@@ -124,8 +124,8 @@ def plot(self, ax=None, zoom=ZOOM, interpolation=INTERPOLATION,
124
124
[Optional. Default='bilinear'] Interpolation
125
125
algorithm to be passed to `imshow`. See
126
126
`matplotlib.pyplot.imshow` for further details.
127
- attribution_text : str
128
- [Optional. Default='' ] Text to be added at the
127
+ attribution : str
128
+ [Optional. Defaults to standard `ATTRIBUTION` ] Text to be added at the
129
129
bottom of the axis.
130
130
131
131
Returns
@@ -152,6 +152,8 @@ def plot(self, ax=None, zoom=ZOOM, interpolation=INTERPOLATION,
152
152
axisoff = True
153
153
ax .imshow (im , extent = bbox , interpolation = interpolation )
154
154
ax .set (xlabel = "X" , ylabel = "Y" )
155
+ if attribution :
156
+ add_attribution (ax , attribution )
155
157
if title is not None :
156
158
ax .set (title = title )
157
159
if axisoff :
@@ -163,7 +165,8 @@ def __repr__(self):
163
165
self .place , self .n_tiles , self .zoom , self .im .shape [:2 ])
164
166
return s
165
167
166
- def plot_map (place , bbox = None , title = None , ax = None , axis_off = True , latlon = True ):
168
+ def plot_map (place , bbox = None , title = None , ax = None , axis_off = True ,
169
+ latlon = True , attribution = ATTRIBUTION ):
167
170
"""Plot a map of the given place.
168
171
169
172
Parameters
@@ -176,6 +179,9 @@ def plot_map(place, bbox=None, title=None, ax=None, axis_off=True, latlon=True):
176
179
The axis on which to plot. If None, one will be created.
177
180
axis_off : bool
178
181
Whether to turn off the axis border and ticks before plotting.
182
+ attribution : str
183
+ [Optional. Default to standard `ATTRIBUTION`] Text to be added at the
184
+ bottom of the axis.
179
185
180
186
Returns
181
187
-------
@@ -208,7 +214,8 @@ def plot_map(place, bbox=None, title=None, ax=None, axis_off=True, latlon=True):
208
214
ax .set (xlabel = "X" , ylabel = "Y" )
209
215
if title is not None :
210
216
ax .set (title = title )
211
-
217
+ if attribution :
218
+ add_attribution (ax , attribution )
212
219
if axis_off is True :
213
220
ax .set_axis_off ()
214
221
return ax
0 commit comments