I have made a map using ggplot and plotted it using ggplotly.
When it is in ggplot it looks like this:
But when it is displayed using ggplotly, it looks like this:
As you can kind of see, the individual regions are sort of splurging all over the place, without clear borders, and the fill is kind of scratchy, as if it's lots of lines rather than a fill. Additionally, the tooltips say things like 'trace 11' for the most part, with the very occasional one displaying relevant data.
This is the core of the code I'm using:
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)
The shapefile I'm using is here.
And this is the head of the data I'm using:
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")
Any ideas what I'm doing wrong?


