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.

Heatmaps are non interactive

See original GitHub issue

Is it normal that Altair heatmaps are non interactive, even when specifying .interactive():

import altair as alt, numpy as np, pandas as pd
x, y = np.meshgrid(range(-5, 5), range(-5, 5))
z = x ** 2 + y ** 2
source = pd.DataFrame({'x': x.ravel(), 'y': y.ravel(), 'z': z.ravel()})
alt.Chart(source).mark_rect().encode(x='x:O', y='y:O', color='z:Q').interactive().save('test2.html')

?

Is there a way to enable interactivity : moving, zooming, etc. in the browser?

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
jakevdpcommented, Nov 8, 2022

I think you’re looking for binned quantitative encodings:

alt.Chart(source).mark_rect().encode(
  x=alt.X('x:Q', bin=True),
  y=alt.Y('y:Q', bin=True),
  color='z:Q'
).interactive()
0reactions
betaigeuzecommented, Nov 30, 2022

PS: would you know if it’s possible to do a “rectangle selection” on such a heatmap, to do a Region Of Interest (ROI) selection?

You can add a rectangular selection with

sel = alt.selection_interval()

So to extend @jakevdp 's example:

sel = alt.selection_interval()

alt.Chart(source).mark_rect().encode(
  x=alt.X('x:Q', bin=True),
  y=alt.Y('y:Q', bin=True),
  color='z:Q'
).add_selection(sel)

However, if you do it like this, you’re dropping the .interactive(). Afaik, you can only assign one function to a mouse click: Either create a selection window or move the plot.

Would you have a link to the right documentation page?

You can read more about this kind of selections here

Read more comments on GitHub >

github_iconTop Results From Across the Web

The 4 potential problems with heatmapping tools
Heat maps without any related quantitative interaction data are notoriously hard to convert into actionable business intelligence ...
Read more >
What Are Heat Maps? Guide to Heatmaps/How to Use Them
A complete guide to website heatmaps with chapters about creating and analyzing heatmaps, ... Getting distracted by non-clickable elements.
Read more >
A Complete Guide to Heatmaps
Heatmaps take the form of a grid of colored squares, where colors correspond with cell value. This article will show you how to...
Read more >
Heat Maps: Types, Benefits & How to Use Them
Heat maps are a simple and powerful tool allowing web designers and your team to understand where users are clicking, tapping and scrolling ......
Read more >
Heat map
A heat map (or heatmap) is a data visualization technique that shows magnitude of a phenomenon as color in two dimensions. The variation...
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