@@ -4400,7 +4400,7 @@ def wmsimage(self,server,\
4400
4400
def drawmapscale (self ,lon ,lat ,lon0 ,lat0 ,length ,barstyle = 'simple' ,\
4401
4401
units = 'km' ,fontsize = 9 ,yoffset = None ,labelstyle = 'simple' ,\
4402
4402
fontcolor = 'k' ,fillcolor1 = 'w' ,fillcolor2 = 'k' ,ax = None ,\
4403
- format = '%d' ,zorder = None ):
4403
+ format = '%d' ,zorder = None , linecolor = None , linewidth = None ):
4404
4404
"""
4405
4405
Draw a map scale at ``lon,lat`` of length ``length``
4406
4406
representing distance in the map
@@ -4434,6 +4434,9 @@ def drawmapscale(self,lon,lat,lon0,lat0,length,barstyle='simple',\
4434
4434
(default white and black). Only relevant for
4435
4435
'fancy' barstyle.
4436
4436
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
4437
4440
============== ====================================================
4438
4441
4439
4442
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',\
4502
4505
# default y offset is 2 percent of map height.
4503
4506
if yoffset is None : yoffset = 0.02 * (self .ymax - self .ymin )
4504
4507
rets = [] # will hold all plot objects generated.
4508
+ # set linecolor
4509
+ if linecolor is None :
4510
+ linecolor = fontcolor
4505
4511
# 'fancy' style
4506
4512
if barstyle == 'fancy' :
4507
4513
#we need 5 sets of x coordinates (in map units)
@@ -4518,13 +4524,13 @@ def drawmapscale(self,lon,lat,lon0,lat0,length,barstyle='simple',\
4518
4524
ybottom = yc - yoffset / 2
4519
4525
ytick = ybottom - yoffset / 2
4520
4526
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 ])
4522
4528
#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 ])
4524
4530
#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 ])
4526
4532
#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 ])
4528
4534
#make a filled black box from left edge to 1/4 way across
4529
4535
rets .append (ax .fill ([x1 ,x2 ,x2 ,x1 ,x1 ],[ytop ,ytop ,ybottom ,ybottom ,ytop ],\
4530
4536
ec = fontcolor ,fc = fillcolor1 )[0 ])
@@ -4538,9 +4544,9 @@ def drawmapscale(self,lon,lat,lon0,lat0,length,barstyle='simple',\
4538
4544
rets .append (ax .fill ([x3 ,x4 ,x4 ,x3 ,x3 ],[ytop ,ytop ,ybottom ,ybottom ,ytop ],\
4539
4545
ec = fontcolor ,fc = fillcolor2 )[0 ])
4540
4546
#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 ])
4544
4550
#label 3 tick marks
4545
4551
rets .append (ax .text (x1 ,ytext ,format % (0 ),\
4546
4552
horizontalalignment = 'center' ,\
@@ -4561,9 +4567,9 @@ def drawmapscale(self,lon,lat,lon0,lat0,length,barstyle='simple',\
4561
4567
fontsize = fontsize ,color = fontcolor ))
4562
4568
# 'simple' style
4563
4569
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 ])
4567
4573
rets .append (ax .text (xc ,yc - yoffset ,format % lenlab ,\
4568
4574
verticalalignment = 'top' ,horizontalalignment = 'center' ,\
4569
4575
fontsize = fontsize ,color = fontcolor ))
0 commit comments