我在 Python 中使用 plotly 创建由一些分类变量着色的美国县的等值线图。由于县太小,因此图像之间的边界线占主导地位。我怎样才能摆脱它们(或将它们的宽度设置为零)?
到目前为止的代码和输出(使用随机数据):
情节:https : //i.stack.imgur.com/G3ltp.png
from urllib.request import urlopen
import json
import numpy as np
import plotly.express as px
import pandas as pd
#Read county geography
with urlopen('https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json') as response:
buf = response.read()
counties = json.loads(buf.decode('utf-8'))
#Create random data
df = pd.DataFrame(np.random.randn(99999, 1),columns=["val"])
df['category']=df['val']>1
df['fips'] = list(range(1,100000))
#Graph
fig = px.choropleth(df, geojson=counties, locations='fips', color='category',
scope="usa")
fig.show()
Run Code Online (Sandbox Code Playgroud)
小智 6
以下应该工作:
fig.update_traces(marker_line_width=0)
Run Code Online (Sandbox Code Playgroud)
https://community.plotly.com/t/adding-state-lines-to-county-level-geojson-based-choropleth/36269
| 归档时间: |
|
| 查看次数: |
1519 次 |
| 最近记录: |