Altair choropleth map, color highlight based on line chart selection
See original GitHub issueHi!
I am plotting a choropleth map colored by the field Passenger_0_
and a line chart showing the evolution of Passenger_0_
throughout a day by zone
.
I would like to select a line (zone
) in the line chart and have it highlighted in the map and vice versa (select a zone in the map and have it highlighted in the line chart).
For now, I am able to change the whole color of the map when selecting the line, but have no clue of how to only change the color of the selected area.
I would appreciate any help. This is the code:
dict_json = json.loads(long_df[long_df['hour']==0].to_json())
colours_obj = alt.Color('properties.Passenger_0_:Q',
scale=alt.Scale(scheme='yelloworangered'),
title = "Pickups")
sel_line_hover = alt.selection_single(on='mouseover', empty='none')
sel_line_col = alt.selection_single()
sel_line_size = alt.selection_single(empty='none')
base = alt.Chart(alt.Data(values=dict_json['features'])).mark_geoshape(
stroke='black',
strokeWidth=1
).encode(
color=alt.condition(sel_line_col, colours_obj, alt.value('lightgray')),
tooltip = ['properties.zone:O',
'properties.Passenger_0_:Q']
).properties(
width=350,
height=750,
).add_selection(
sel_line_col
)
line = alt.Chart(long_df).mark_line().encode(
x='hour',
y='Passenger_0_',
color=alt.condition(sel_line_hover|sel_line_col, 'zone', alt.value('lightgray')),
size=alt.condition(sel_line_hover|sel_line_size, alt.value(4),alt.value(1)),
tooltip = ['zone:O']
).properties(
width=250,
height=750,
).add_selection(
sel_line_hover,sel_line_col,sel_line_size
)
base | line
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top Results From Across the Web
Altair choropleth map, color highlight based on line chart ...
I would like to select a line ( zone ) in the line chart and have it highlighted in the map and vice...
Read more >Altair Choropleth Map, Color Highlight Based On ... - ADocLib
This gallery contains a selection of examples of the plots Altair can create. glance but they are built by combining a simple set...
Read more >Interactive choropleth maps in python using Altair, Plotly and ...
A Step by step guide to create interactive map visuals in python using opensource libraries - Altair, Plotly and Folium .
Read more >Example Gallery — Altair 4.2.0 documentation
This gallery contains a selection of examples of the plots Altair can create. ... Bar Chart with Highlighted Bar Bar Chart with Labels...
Read more >Guide to Altair Panopticon 2021.2 Visualizations
Trending performance between two numeric variables Numeric Line Graph ... A Heat Map is a special type of color-based data visualization that is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you very much for your answer @joelostblom I haven´t had time to try your solution but I will close this issue until I test it.
Answered on SO.. @angelrps if my reply there solves your problem, could you close this issue?