Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HeatMap doesn't work with datetime very well // can we specify bins? #6185

Open
runburg opened this issue Apr 12, 2024 · 0 comments
Open

HeatMap doesn't work with datetime very well // can we specify bins? #6185

runburg opened this issue Apr 12, 2024 · 0 comments

Comments

@runburg
Copy link

runburg commented Apr 12, 2024

So I have run into this issue several times where when I construct a HeatMap with gaps in the datetime dimension, the bins that are chosen are wrong. Or at least they get displayed wrong. I haven't noticed this with other dimension types, only datetime/timestamp.

This is fixed if I make sure to use continuous datetime data (but in practice I don't know of a way to ensure this from a pandas dataframe or xarray).

holoviews v1.18.3

import pandas as pd
import numpy as np
import holoviews as hv
import random

hv.extension('bokeh')
dates = pd.date_range(pd.Timestamp('2024-01-01 12:00:00'), pd.Timestamp('2024-01-01 14:00:00'), freq=pd.Timedelta('1 min'))

nums = np.linspace(0, 50, num=20)
hm = []
for d in dates[:10].union(dates[-10:]):
    for n in nums:
        hm.append((d, n, random.randint(0, 50)))

hv.HeatMap(hm, kdims=['date', 'num'], vdims='random').opts(tools=['hover'])

On a somewhat related note, I have several questions:

  • Is there a way to specify the bins or bin sizes that HeatMap uses?
  • Does anyone know of a way to fill/resample my data (DataFrame, Xarray, or holoviews Dataset) to regular time intervals (filling unsampled times with NaN) as a workaround?

Screenshots or screencasts of the bug in action

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant