Choropleth Map produces just a coloured rectangle
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- R
- Star
- 2.7k
- Fork
- 641
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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?
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện hai trace trong issue với Natural Earth GeoJSON được liên kết, rồi so sánh đầu ra choroplethmapbox đang hoạt động với đầu ra choropleth có màu phẳng. Theo dõi cách trace choropleth của R xử lý geojson, featureidkey, locations và z; được xem là hoàn tất khi choropleth tiêu chuẩn hiển thị rõ ràng các giá trị của từng quốc gia, đồng thời hành vi hover đối với các locations bị thiếu đã được xử lý hoặc làm rõ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- r
- Lĩnh vực
- data-visualization
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100