Choropleth Map produces just a coloured rectangle
Personne n'a encore pris cette issue.
- Langage dominant
- R
- Étoiles
- 2.7k
- Forks
- 641
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
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?
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par reproduire les deux traces de l’issue avec le Natural Earth GeoJSON associé, puis comparez la sortie fonctionnelle de choroplethmapbox avec la sortie du choropleth à couleur uniforme. Suivez la manière dont la trace choropleth de R gère geojson, featureidkey, locations et z ; le travail est considéré comme terminé lorsque le choropleth standard affiche distinctement les valeurs des pays et que le comportement du survol pour les locations manquantes est traité ou clarifié.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- r
- Domaine
- data-visualization
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 45/100