Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

Adding two layers with different color scales to a map figure

$
0
0

Hi - I need to be able to add two layers to a plotly map chart. The first is a choropleth and the second is a scatter_mapbox figure. I can get this code to work however, what I haven’t been able to figure out is whether it’s possible to have two different color scales for the two layers. On the first layer, I want to use a field to determine the shading on the choropleth, and on the second layer, I want to be able to use a different variable on a different scale to determine the color of scatter bubbles. Is this possible? I’ve tried to do this and the color of the second layer keeps defaulting to the color and scale of the first layers color variable. Any help is much appreciated. Thanks

Code is below:

fig = px.choropleth_mapbox(df_summ, geojson=city_boundaries,color_continuous_scale=px.colors.diverging.Geyser, color=‘price_persqft’,
locations=“places”, featureidkey=“properties.places”, opacity=0.34, zoom=10, height=1700,
center={“lat”: 37.7555, “lon”: -122.4447},
)

fig2 = px.scatter_mapbox(df3, lat=“latitude”, lon=“longitude”, size=‘description.sqft’, color=“description.sold_price”, hover_name=‘location.address.line’,
hover_data=[‘price2’,‘description.beds’,‘description.sold_date’,‘location.address.city’,‘location.address.postal_code’], size_max=14,
)

fig.add_trace(fig2.data[0])

fig.show()

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 6271

Trending Articles