show geometries for both categorical and numerical fields in the same plot - px.choropleth
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 18.8k
- フォーク
- 2.8k
- 平均マージ
- 16時間 26分
- マージ済み PR(30日)
- 21
説明
I am trying to create a US county map (including AK and HI in the bottom corner of the continental map) in plotly. I do not have numerical data for every county. In fact I only have data for 50 counties (approx). I want the map to contain the geometry for the for the counties with not data, so I can plot them in a different color. Otherwise the map is to empty. I tried with add.trace but I could not make it work.
``
import plotly.graph_objs as go
import plotly.express as px
import pandas as pd
from urllib.request import urlopen
import json
with urlopen('https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json') as response:
counties = json.load(response)
df = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/fips-unemp-16.csv",
dtype={"fips": str})
df_nodata=df.loc[df.unemp <= 10]
df_nodata['categorical'] = 'no data'
df_data = df.loc[df.unemp > 10]
fig = px.choropleth(df_data,
geojson=counties,
locations=df_data.fips,
color=df_data.unemp,
scope='usa')
fig.add_trace(go.Figure(go.Choroplethmapbox(geojson=counties, locations=df_nodata.fips, z=df_nodata.categorical))
)
fig.show()
``
I am trying to combine the attached


layers.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず px.choropleth を使った例と、試行した go.Choroplethmapbox trace を再現し、その後、これらのエントリーポイントが地理レイヤーをどのように構成しているかを調べます。結果には、同じ米国のマップ上でデータのある郡とデータのない郡を表示し、データのない郡には異なる色を使用します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- data-visualization
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100