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

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

Closed
1 task done
nfi-hashicorp opened this issue Aug 27, 2024 · 0 comments · Fixed by #6365
Closed
1 task done

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

nfi-hashicorp opened this issue Aug 27, 2024 · 0 comments · Fixed by #6365
Labels
type: bug Something isn't correct or isn't working

Comments

@nfi-hashicorp
Copy link

nfi-hashicorp commented Aug 27, 2024

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
@hoxbro hoxbro added the type: bug Something isn't correct or isn't working label Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't correct or isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants