在對這個問題R - plotly - combine bubble and chorpleth map的回答中,很好地描述瞭如何在一張地圖內積極地組合泡泡和等值線圖。我想在Python中複製完全相同的示例,但我沒有根據劇情文檔(https://plot.ly/python/reference/)中提供的信息進行管理。Python - 積極地 - 結合泡沫和等值線地圖
等效R代碼裏面的內容如下:
lon = c(-73.9865812, -118.2427266, -87.6244212, -95.3676974)
pop = c(8287238, 3826423, 2705627, 2129784)
df_cities = data.frame(cities, lat, lon, pop)
state_codes = c("NY", "CA", "IL", "TX")
pop = c(19746227.0, 38802500.0, 12880580.0, 26956958.0)
df_states = data.frame(state_codes, pop)
plot_ly(df_cities, lon=lon, lat=lat,
text=paste0(df_cities$cities,'<br>Population: ', df_cities$pop),
marker= list(size = sqrt(pop/10000) + 1), type="scattergeo",
filename="stackoverflow/choropleth+scattergeo") %>%
add_trace(z=df_states$pop,
locations=df_states$state_codes,
text=paste0(df_states$state_codes, '<br>Population: ', df_states$pop),
type="choropleth",
colors = 'Purples',
locationmode="USA-states") %>%
layout(geo = list(scope="usa"))
這怎麼能在Python中實現?
這是不一樣的問題蟒回答被詢問 – spacetyper