1

I'd like to display an altair scatterplot in a jupyter notebook. When a user clicks on a specific point (or, I suppose a range of points), I'd like update the results in another cell. Similar to ipywidgets.

As a more specific example, say I have a dataframe which contains the following columns: state, county, population, income

I'm mapping population to the X axis and income to the Y axis. Each dot represents the state (counties are aggregated away).

I'd like to click on a dot (state) and update the results of a data frame where the filter is set to the selected state. So each click will result in the other cell being updated with counties just in that state.

I figured altair would have some sort of callback where I could do this update but I don't see it in the docs.

I also have matplotlib and seaborn available to me, if this can be done with those packages.

I'm in a pretty locked down environment so can't install additional packages (such as plotly).

Shahbaz
  • 10,395
  • 21
  • 54
  • 83
  • Could you add the code that you have so far? – Yulia V Jul 21 '21 at 19:42
  • @YuliaV, unfortunately I can't paste the code. Even this problem is made up, I'm not actually working with states/counties data. The main question really is, how can I use interactive plots to explore my data? – Shahbaz Jul 21 '21 at 20:01
  • 1
    https://stackoverflow.com/questions/22052532/matplotlib-python-clickable-points – Yulia V Jul 21 '21 at 20:05

1 Answers1

0

Altair provides no supported way to dynamically update charts across cells of a Jupyter notebook. It could probably be done in Javascript via the Vega View API, but I'm not aware of any example of this.

jakevdp
  • 77,104
  • 11
  • 125
  • 160