Arihant
Arihant

Reputation: 589

Change map scale bar color R

I have a map plot with black background and other layout elements in black color except the map scale. I have tried changing the graphical parameters but that doesn't change the color of the scale bar.I have been able to change the color of the text/label on the scale but the scale line doesn't show up as white color.
I am using the "maps" package.

Here is my code :

require(maps)
map.scale(x=-112.89, y=36.851, ratio=F, metric = T, relwidth=0.2, col ="white")

The help file mentions that "Further plotting parameters may be specified as for the command text()" but I do not know how I can change the scale bar(line) color to white.I am still trying to put the map layout image in here but I need to figure out how that works. Any help will be appreciated.

Upvotes: 1

Views: 1559

Answers (1)

thelatemail
thelatemail

Reputation: 93908

You could always edit the map.scale function, as I don't think the colour of the line is a changeable part of the function as it is:

map.scale2 <- map.scale

Then edit the new function:

fix(map.scale2)

Change line 1 from

function (x, y, relwidth = 0.15, metric = TRUE, ratio = TRUE, 

to

function (x, y, relwidth = 0.15, metric = TRUE, ratio = TRUE, linecol="black",

and change line 42 from

lines(linexy)

to

lines(linexy,col=linecol)

Then you could give it a crack and run it as you intended:

map.scale2(x=-112.89, y=36.851, ratio=F, metric = T, relwidth=0.2, col ="white", linecol="white")

Upvotes: 2

Related Questions