简体   繁体   English

更改地图比例尺颜色R

[英]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. 帮助文件中提到“可以为命令text()指定更多的绘图参数”,但是我不知道如何将比例尺(线)的颜色更改为白色。我仍在尝试将地图布局图像放入在这里,但我需要弄清楚它是如何工作的。 Any help will be appreciated. 任何帮助将不胜感激。

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.scale函数,因为我认为线条的颜色并不是函数的可变部分,因为它是这样的:

map.scale2 <- map.scale

Then edit the new function: 然后编辑新功能:

fix(map.scale2)

Change line 1 from 将第1行从

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 并将第42行从

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")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM