Skip to content

Bars in Overlays with timezone-aware datetimes shows a big black box #6364

@nfi-hashicorp

Description

@nfi-hashicorp

ALL software version info

Using VS Code ipython notebook, bokeh backend, macOS 14.5

[tool.poetry]
name = "blah"
version = "0.1.0"
description = ""
authors = ["Nick Irvine <115657443+nfi-hashicorp@users.noreply.github.com>"]

[tool.poetry.dependencies]
python = "^3.12"
numpy = "^2.1.0"
pandas = "^2.2.2"
holoviews = "^1.19.1"


[tool.poetry.group.dev.dependencies]
ipykernel = "^6.29.5"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
% code --version
1.92.1
eaa41d57266683296de7d118f574d0c2652e1fc4
arm64

Description of expected behavior and the observed behavior

When combining data with tz-aware datetimes, bars and overlays, we get this garbled mess:

image

instead of this:

image

Complete, minimal, self-contained example code that reproduces the issue

Based on bars example

import holoviews as hv
import pandas as pd
hv.extension('bokeh')
from bokeh.plotting import show

data = pd.DataFrame({"x": pd.date_range("2017-01-01", "2017-01-03"), "y": [0, 2, -1]})
data_utc = pd.DataFrame({"x": pd.date_range("2017-01-01", "2017-01-03", tz="UTC"), "y": [0, 2, -1]})

bars = hv.Bars(data, ["x"], ["y"])
bars_utc = hv.Bars(data_utc, ["x"], ["y"])
# works
show(hv.render(bars))
# works
show(hv.render(hv.Overlay([bars])))
# works
show(hv.render(bars_utc))
# busted
show(hv.render(hv.Overlay([bars_utc])))

Renders as:

image

Workaround

Strip the timezone

data_stripped = data_utc.copy()
data_stripped["x"] = data_utc["x"].apply(lambda x: x.tz_convert(None))
bars_stripped = hv.Bars(data_stripped, ["x"], ["y"])
show(hv.render(hv.Overlay([bars_stripped])))
image
  • I may be interested in making a pull request to address this

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething isn't correct or isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions