【发布时间】:2019-02-06 09:40:22
【问题描述】:
我使用 ggplot 制作了一张地图,并使用 ggplotly 绘制了它。
当它在 ggplot 中时,它看起来像这样:
但是用ggplotly显示的时候是这样的:
正如您所看到的,各个区域有点乱七八糟,没有清晰的边界,而且填充有点沙哑,好像是很多线条而不是填充。此外,工具提示大部分都说“trace 11”之类的内容,偶尔会显示相关数据。
这是我正在使用的代码的核心:
random_map <- ggplot() +
geom_map(data = random_data, aes(map_id = random_data$ï..CCG, fill = random_data$Number),
map = CCGshape) +
geom_polygon (data = CCGshape, aes(x = long, y = lat, group = group),
colour = "azure4", size = 0.01, fill = NA) +
expand_limits(x = CCGshape$long, y = CCGshape$lat) +
coord_equal ()
random_plotly <- ggplotly(random_map)
我使用的 shapefile 是 here。
这是我正在使用的数据的头部:
structure(list(Number = c(1, 0.4, 0.9, 0.3, 0.3, 0.7),
CCG = c("NHS Airedale, Wharfedale and Craven CCG",
"NHS Barnsley CCG", "NHS Bassetlaw CCG", "NHS Bradford Districts CCG",
"NHS Calderdale CCG", "NHS Bradford City CCG")), .Names = c("Number",
"CCG"), row.names = c(NA, 6L), class = "data.frame")
任何想法我做错了什么?
【问题讨论】:
标签: r ggplot2 maps r-plotly ggplotly