pip install plotly
import plotly.graph_objects as go
import pandas as pd
df = pd.read_excel('C:/Python/US/US.xlsx',sheet_name='1')
locations=df['code'], # 设置位置,各州的编号(缩写)
z = df['conNum'].astype(float), # 设置填充色数据
locationmode = 'USA-states', # 设置国家名称
colorscale = 'Reds', # 图例颜色
colorbar_title = "人数", # 图例标题
))fig.update_layout(
title_text = '美国累计确诊人数', # 地图标题
geo_scope='usa', # 设置地图的范围为美国
#scope可选有"world","usa","europe","asia","africa","north america","south america"
)
fig.write_html("C:/Python/US/US.html")