Choropleth Map produces just a coloured rectangle
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- R
- Estrellas
- 2.7k
- Forks
- 641
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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?
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza reproduciendo los dos traces del issue con el Natural Earth GeoJSON enlazado y compara la salida funcional de choroplethmapbox con la salida del choropleth de color plano. Sigue cómo el trace de choropleth de R gestiona geojson, featureidkey, locations y z; se considera terminado cuando el choropleth estándar muestra los valores de los países de forma diferenciada y el comportamiento del hover para las locations que faltan está resuelto o aclarado.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- r
- Área
- data-visualization
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100