I just can't get plot_geo
to display correctly.
This is weird, because I can use other plotly
commands, including ggplotly
, to create interactive plots. I am running R version 3.3.3 and RStudio version 1.1.350 with plotly
version 4.7.1.
Initially, I call on 3 packages by recommendation I saw here: plot-geo-returning-a-blank-map-in-r
library(dplyr)
library(ggplot2)
library(plotly)
map_data("world", "canada") %>%
group_by(group) %>%
plot_geo(x = ~long, y = ~lat) %>%
add_markers(size = I(1))
I get an empty plot, but if I hover over it, I can see the latitude and longitude information.
Map data in ggplot2
works to seem fine as I can run this example without a problem:
if (require("maps")) {
states <- map_data("state")
arrests <- USArrests
names(arrests) <- tolower(names(arrests))
arrests$region <- tolower(rownames(USArrests))
choro <- merge(states, arrests, sort = FALSE, by = "region")
choro <- choro[order(choro$order), ]
ggplot(choro, aes(long, lat)) +
geom_polygon(aes(group = group, fill = assault)) +
coord_map("albers", at0 = 45.5, lat1 = 29.5)
ggplot(choro, aes(long, lat)) +
geom_polygon(aes(group = group, fill = assault / murder)) +
coord_map("albers", at0 = 45.5, lat1 = 29.5)
}
Would anyone know how to debug this problem?
I've tried to reinstall ggplot2
and plotly
from both CRAN and GitHub without much luck.