我正在尝试在绘制和sf对象的区域上更改边框颜色。更改边框的颜色很好,但是线条有点细,所以我只想使彩色线条更粗,以便于显示。
阅读this question表示使用“ lwd”将允许更改厚度。但是,当我尝试时,我没有任何效果,或者线条太粗。
请参见下面的示例
library(sf)
library(ggplot)
library(dplyr)
nc <- st_read(system.file("shape/nc.shp", package="sf")) %>%
mutate(type= case_when(
BIR74>16000 ~"High",
TRUE ~"Low"
) %>% factor(levels = c("Low", "High"))) #the levels are ordered to avoid the grey lines overwriting the red ones
nc %>%
ggplot(.) +
geom_sf(aes(fill = BIR74, colour = type)) + #does the job but the coloured borders are quite thing
scale_color_manual(values = c( "#666666","#F8766D"))
nc %>%
ggplot(.) +
geom_sf(aes(fill = BIR74, colour = type,
lwd = ifelse(type =="High", 1, 0.5)) #The values can be anything and it still looks rubbish
) +
scale_color_manual(values = c( "#666666","#F8766D"))
我怎样才能只获得合理的厚度,例如x%的厚度?理想情况下,只改变目标边缘。
答案 0 :(得分:0)
您可能想在val result = getResult(1)
when(result) {
is String -> { do a thing }
is Int -> { do a thing }
}
之外使用lwd
参数:
aes
祝你好运!