question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Altair selections resolve incorrectly as scale domain values.

See original GitHub issue

I 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:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jakevdpcommented, Apr 13, 2019

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 of add_selection. It would take a bit of refactoring, but probably would be better.

0reactions
jakevdpcommented, Apr 13, 2019

See #1433

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found