R语言绘制美国地图

    科技2023-10-11  109

    #R语言绘制美国地图 library(maps) library(ggplot2) qplot(long,lat,data=us.cities,color=('blue'))+borders("state",size=0.5) library(plotly) library(xlsx) library(DT) df <- read.xlsx2("D:\\R\\america.xlsx",sheetIndex = 1) #读取表格 df$hover <- with(df, paste(state, '<br>', "确诊人数:", definte,"<br>","死亡人数:", death, "<br>","死亡率:",rate,"%")) #鼠标放上显示相关数据 fig <- plot_geo(df, locationmode = 'USA-states') #将表格数据与美国地图关联 #交互 fig <- fig %>% add_trace( locations = ~code, type='choropleth', z= ~definte, text = ~hover, colorscale="Reds" ) #添加标题 fig <- fig %>% layout(title = "美国疫情状况") #显示 fig

    Processed: 0.017, SQL: 8