Skip to content

Commit 6c6c398

Browse files
authored
Merge pull request #331 from mlegner/master
Add keyword arguments `linewidth' and `linecolor' to drawmapscale.
2 parents b80bfdc + cc2d101 commit 6c6c398

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

lib/mpl_toolkits/basemap/__init__.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4400,7 +4400,7 @@ def wmsimage(self,server,\
44004400
def drawmapscale(self,lon,lat,lon0,lat0,length,barstyle='simple',\
44014401
units='km',fontsize=9,yoffset=None,labelstyle='simple',\
44024402
fontcolor='k',fillcolor1='w',fillcolor2='k',ax=None,\
4403-
format='%d',zorder=None):
4403+
format='%d',zorder=None,linecolor=None,linewidth=None):
44044404
"""
44054405
Draw a map scale at ``lon,lat`` of length ``length``
44064406
representing distance in the map
@@ -4434,6 +4434,9 @@ def drawmapscale(self,lon,lat,lon0,lat0,length,barstyle='simple',\
44344434
(default white and black). Only relevant for
44354435
'fancy' barstyle.
44364436
zorder sets the zorder for the map scale.
4437+
linecolor sets the color of the scale, by default, fontcolor
4438+
is used
4439+
linewidth linewidth for scale and ticks
44374440
============== ====================================================
44384441
44394442
Extra keyword ``ax`` can be used to override the default axis instance.
@@ -4502,6 +4505,9 @@ def drawmapscale(self,lon,lat,lon0,lat0,length,barstyle='simple',\
45024505
# default y offset is 2 percent of map height.
45034506
if yoffset is None: yoffset = 0.02*(self.ymax-self.ymin)
45044507
rets = [] # will hold all plot objects generated.
4508+
# set linecolor
4509+
if linecolor is None:
4510+
linecolor = fontcolor
45054511
# 'fancy' style
45064512
if barstyle == 'fancy':
45074513
#we need 5 sets of x coordinates (in map units)
@@ -4518,13 +4524,13 @@ def drawmapscale(self,lon,lat,lon0,lat0,length,barstyle='simple',\
45184524
ybottom = yc-yoffset/2
45194525
ytick = ybottom - yoffset/2
45204526
ytext = ytick - yoffset/2
4521-
rets.append(self.plot([x1,x4],[ytop,ytop],color=fontcolor)[0])
4527+
rets.append(self.plot([x1,x4],[ytop,ytop],color=linecolor, linewidth=linewidth)[0])
45224528
#plot bottom line
4523-
rets.append(self.plot([x1,x4],[ybottom,ybottom],color=fontcolor)[0])
4529+
rets.append(self.plot([x1,x4],[ybottom,ybottom],color=linecolor, linewidth=linewidth)[0])
45244530
#plot left edge
4525-
rets.append(self.plot([x1,x1],[ybottom,ytop],color=fontcolor)[0])
4531+
rets.append(self.plot([x1,x1],[ybottom,ytop],color=linecolor, linewidth=linewidth)[0])
45264532
#plot right edge
4527-
rets.append(self.plot([x4,x4],[ybottom,ytop],color=fontcolor)[0])
4533+
rets.append(self.plot([x4,x4],[ybottom,ytop],color=linecolor, linewidth=linewidth)[0])
45284534
#make a filled black box from left edge to 1/4 way across
45294535
rets.append(ax.fill([x1,x2,x2,x1,x1],[ytop,ytop,ybottom,ybottom,ytop],\
45304536
ec=fontcolor,fc=fillcolor1)[0])
@@ -4538,9 +4544,9 @@ def drawmapscale(self,lon,lat,lon0,lat0,length,barstyle='simple',\
45384544
rets.append(ax.fill([x3,x4,x4,x3,x3],[ytop,ytop,ybottom,ybottom,ytop],\
45394545
ec=fontcolor,fc=fillcolor2)[0])
45404546
#plot 3 tick marks at left edge, center, and right edge
4541-
rets.append(self.plot([x1,x1],[ytick,ybottom],color=fontcolor)[0])
4542-
rets.append(self.plot([xc,xc],[ytick,ybottom],color=fontcolor)[0])
4543-
rets.append(self.plot([x4,x4],[ytick,ybottom],color=fontcolor)[0])
4547+
rets.append(self.plot([x1,x1],[ytick,ybottom],color=linecolor, linewidth=linewidth)[0])
4548+
rets.append(self.plot([xc,xc],[ytick,ybottom],color=linecolor, linewidth=linewidth)[0])
4549+
rets.append(self.plot([x4,x4],[ytick,ybottom],color=linecolor, linewidth=linewidth)[0])
45444550
#label 3 tick marks
45454551
rets.append(ax.text(x1,ytext,format % (0),\
45464552
horizontalalignment='center',\
@@ -4561,9 +4567,9 @@ def drawmapscale(self,lon,lat,lon0,lat0,length,barstyle='simple',\
45614567
fontsize=fontsize,color=fontcolor))
45624568
# 'simple' style
45634569
elif barstyle == 'simple':
4564-
rets.append(self.plot([x1,x4],[yc,yc],color=fontcolor)[0])
4565-
rets.append(self.plot([x1,x1],[yc-yoffset,yc+yoffset],color=fontcolor)[0])
4566-
rets.append(self.plot([x4,x4],[yc-yoffset,yc+yoffset],color=fontcolor)[0])
4570+
rets.append(self.plot([x1,x4],[yc,yc],color=linecolor, linewidth=linewidth)[0])
4571+
rets.append(self.plot([x1,x1],[yc-yoffset,yc+yoffset],color=linecolor, linewidth=linewidth)[0])
4572+
rets.append(self.plot([x4,x4],[yc-yoffset,yc+yoffset],color=linecolor, linewidth=linewidth)[0])
45674573
rets.append(ax.text(xc,yc-yoffset,format % lenlab,\
45684574
verticalalignment='top',horizontalalignment='center',\
45694575
fontsize=fontsize,color=fontcolor))

0 commit comments

Comments
 (0)