require(ggvis)
require(dplyr)
map_data = ggplot2::map_data("world")
map_data %>% select(long, lat, group) %>%
group_by(group) %>%
ggvis(x = ~long, y = ~lat) %>% layer_paths(fill:="#666666") %>%
hide_axis("x") %>% hide_axis("y")
这会产生一个漂亮的地图,但我想控制“海洋”颜色(例如“黑色”)。怎么做?
更一般地说,海洋颜色是情节默认背景。
答案 0 :(得分:4)
添加layer_rects似乎已经完成了:
require(ggvis)
require(dplyr)
map_data = ggplot2::map_data("world")
minx = min(map_data$long -1)
maxx = max(map_data$long +1)
miny = min(map_data$lat - 1)
maxy = max(map_data$lat + 1)
map_data %>% select(long, lat, group) %>%
group_by(group) %>%
ggvis(x = ~long, y = ~lat) %>%
layer_rects(x=minx, x2=maxx, y=maxy, y2=miny, fill:="#000000") %>%
layer_paths(fill:="#666666") %>%
hide_axis("x") %>% hide_axis("y")