The code for the second plot
map.options <- list(
scope = 'usa',
projection = list(type='albers usa'),
showlakes = TRUE,
lakecolor = toRGB('grey')
)
borders <- list(color=toRGB("red"))
plot_ly(dat, z=dat$Population,
text=paste(dat$State, '<br>', dat$Abbreviation, '<br>',
"Population: ", dat$Population,
'<br>', "Winner: ", dat$Winnner),
locations=dat$Abbreviation,type = "choropleth",
locationmode='USA-states',
color = dat$Population,
colors='Blues',
marker=list(line=borders)) %>%
layout(title="USA Presedential Election Results in 2014", geo=map.options)