show geometries for both categorical and numerical fields in the same plot - px.choropleth
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 18.8k
- Forks
- 2.8k
- Ø Merge
- 16 Std. 26 Min.
- Gemergte PRs (30 T.)
- 21
Beschreibung
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.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, das Beispiel mit px.choropleth und den versuchten go.Choroplethmapbox-Trace nachzustellen, und untersuche anschließend, wie diese Einstiegspunkte geografische Layer zusammensetzen. Das Ergebnis sollte Countys mit Daten und Countys ohne Daten auf derselben US-Karte anzeigen, wobei die Countys ohne Daten eine unterscheidbare Farbe verwenden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- data-visualization
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100