Choropleth Map produces just a coloured rectangle
まだ誰も着手していません。
- 主要言語
- R
- スター
- 2.7k
- フォーク
- 641
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
I am trying to draw a Plotly choropleth map using a custom geojson created using the Natural Earth 10m map-unit dataset. (I need Wales/Scotland/Ireland/England etc).
If I plot with mapbox I get the expected output (although my polygons don't quite fit the background) however if I try to just use choropleth I get a square of just one colour (I can still see hover values though).
A subset of my data for USSR countries:
library(data.table)
library(plotly)
countries <- rjson::fromJSON(file="https://raw.githubusercontent.com/awgymer/map-data/master/ne_10m_admin_0_map_units.json")
first_gms <- fread(
"team_name,geounit,played_for
USSR,BLR,14671
USSR,TJK,6516
USSR,UZB,12484
USSR,MDA,7007
USSR,UKR,739
USSR,KAB,7182
USSR,LVA,6559
USSR,KAZ,7182
USSR,ARM,10895
USSR,RUS,6516
USSR,AZE,11213
USSR,KGZ,12481
USSR,GEA,5518
USSR,EST,14671
USSR,TKM,6516
USSR,GEG,5518
USSR,LTU,6845")
fig <- plot_ly(first_gms) %>% add_trace(
type="choroplethmapbox",
geojson=boundaries,
featureidkey="properties.GU_A3",
z=~played_for,
locations=~geounit,
colorscale="Viridis",
marker=list(line=list(
width=0)
)
) %>% layout(
mapbox=list(
style="carto-positron"
)
)
fig2 <- plot_ly(first_gms) %>% add_trace(
type="choropleth",
geojson=boundaries,
featureidkey="properties.GU_A3",
z=~played_for,
locations=~geounit,
colorscale="Viridis",
marker=list(line=list(
width=0)
)
) %>% layout(
geo = list(resolution=50)
)
fig works but fig2 is just all one colour. I cannot for the life of me work out the reason!
As an addendum: Is there any way to specify hover for countries which have no value in z/locations?
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、リンクされた Natural Earth GeoJSON を使って issue 内の 2 つの trace を再現し、動作している choroplethmapbox の出力と単色の choropleth の出力を比較します。R の choropleth trace が geojson、featureidkey、locations、z をどのように処理するかを追跡します。標準の choropleth で国の値が明確に区別して表示され、欠落している locations に対する hover の動作が対処または明確化されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- r
- 領域
- data-visualization
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100