Showing geometries for both categorical and numerical fields in the same plot - px.choropleth
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.
Hi - we are trying to tidy up the stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for several years, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. Thanks for your help - @gvwilson
Hi Unfortunately I’m still having issues plotting geographies on a map. Would you be able to provide and example plotting any geography others than counties?Thanks Sent from my iPhoneOn Jun 25, 2024, at 2:05 PM, Greg Wilson @.***> wrote: Hi - we are trying to tidy up the stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for several years, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. Thanks for your help - @gvwilson
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>
@archmoj will this be addressed by your current work?