python - Plotly Choropleth 不使用 ISO 代码显示颜色
问题描述
我希望在美国绘制计数(频率)和区域(使用区域 ISO 代码)的等值线。我目前正在使用情节,但我似乎无法弄清楚为什么不显示应该显示频率的颜色。我没有 fibs 专栏,我只有 ISO。
谢谢..
from urllib.request import urlopen
import pandas as pd
import plotly.express as px
import json
from pyspark.sql.types import IntegerType
# with urlopen('https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json') as # response:
# counties = json.load(response)
df = location_test.toPandas()
fig = px.choropleth_mapbox(df, locations=df['location_region_iso_code'], color=df['count'],
color_continuous_scale="Viridis",
range_color=(0, 15),
mapbox_style="carto-positron",
zoom=3, center = {"lat": 37.0902, "lon": -95.7129},
opacity=0.5,
labels={'count':'Count'}
)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()
解决方案
推荐阅读
- swiftui - 使用文本和滑块 swiftUI 创建 HStack 的垂直堆栈
- python - 仅对满足 Python 中特定条件的像素执行 2D 卷积
- c# - 如果输入参数不为空,MySql 更新
- javascript - 如何以角度向API服务异步添加数据(需要迭代两次)?
- android - Android 向上滑动以打开画廊,就像在 whatsapp 相机中一样
- python - Seaborn 中的自定义图表格式
- python - 拆分成str后加入列表元素
- python - 如何将变量从一个 Tkinter 窗口传递到另一个窗口?
- html - 我的 XPath 不适用于所有场景
- javascript - TypeError:无法读取未定义的属性“单词”。在 React 中使用 CypherJS