Altair selections resolve incorrectly as scale domain values.
See original GitHub issueI am observing this issue in Altair 2.x. Apologies if this issue has already been addressed for v3!
The following code for an overview + detail plot fails:
brush = alt.selection_interval(encodings=['x']);
base = alt.Chart().mark_area().encode(
x=alt.X('date:T', title=None),
y='price:Q'
).properties(
width=700
)
alt.vconcat(
base.encode(alt.X('date:T', title=None, scale=alt.Scale(domain=brush))),
base.add_selection(brush).properties(height=60),
data='https://vega.github.io/vega-datasets/data/sp500.csv'
)
The errors indicate that Altair is expanding the brush to the full selection definition (what you would use for add_selection
) rather than generating a selection reference. If I add name='brush'
to the selection definition and then replace domain=brush
with domain={'selection': 'brush'}
, the example works.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Customizing Visualizations — Altair 4.2.0 documentation
To make a custom mapping of discrete values to colors, use the domain and range parameters of the Scale class for values and...
Read more >Fix scale botttom colour on 0 in altair - python - Stack Overflow
You can set the domain of the color scale the same way you set it for an axes: scale=alt.Scale(range=["transparent", "green"], domain=[0, ...
Read more >Data Types, Graphical Marks, and Visual Encoding Channels
We will start by looking at the basic data types that Altair uses to inform visual encoding choices. These data types determine the...
Read more >RADIOSS User's Guide - Altair Community
domains. Number of RADIOSS SPMD MPI domains. (Example: radioss –np 4 ... The time step scale factor value is set to 0.9 by...
Read more >Python Examples of altair.Color - ProgramCreek.com
Python altair. ... Scale( domain=(display_df.dropna().trending.min(), 0, ... color=alt.condition( abs(alt.datum.z) < 0.8, alt.value('black'), ...
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
One way we could maybe improve this is to not make Altair selections equivalent Vega-Lite selection objects, but rather make them objects with a JSON representation of
{selection: "name"}
, but which resolve the same way as selection objects within the context ofadd_selection
. It would take a bit of refactoring, but probably would be better.See #1433