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

hv.render ignores theme bgcolor #6357

Open
1 task done
AlonKellner opened this issue Aug 7, 2024 · 0 comments
Open
1 task done

hv.render ignores theme bgcolor #6357

AlonKellner opened this issue Aug 7, 2024 · 0 comments

Comments

@AlonKellner
Copy link

Version Info

Colab versions

On the latest Colab (released on 2024-07-22) with Google Chrome (127.0.6533.74) after updating pip versions:

>>> pip install -qU jupyter_bokeh panel holoviews bokeh

These are the relevant pip versions to reproduce this:

>>> pip freeze | grep -e holoviews -e bokeh -e panel -e numpy
bokeh==3.4.3
holoviews==1.19.1
jupyter_bokeh==4.0.5
numpy==1.26.4
panel==1.4.5

VSCode versions

On VSCode:

Version: 1.92.0 (user setup)
Commit: b1c0a14de1414fcdaa400695b4db1c0799bc3124
Date: 2024-07-31T23:26:45.634Z
Electron: 30.1.2
ElectronBuildId: 9870757
Chromium: 124.0.6367.243
Node.js: 20.14.0
V8: 12.4.254.20-electron.0
OS: Windows_NT x64 10.0.26257

with devcontainers, based on the python devcontainer image:
mcr.microsoft.com/devcontainers/python:1-3.10-bookworm
with the full devcontainer configureation in here.
after updating pip versions:

>>> pip install -qU jupyter_bokeh panel holoviews bokeh

These are the relevant pip versions to reproduce this:

>>> pip freeze | grep -e holoviews -e bokeh -e panel -e numpy
bokeh==3.4.3
holoviews==1.19.1
jupyter_bokeh==4.0.5
numpy==2.0.1
panel==1.4.5

Behavior

Expected

In all cases when hv.renderer('bokeh').theme = 'dark_minimal' is used, the theme should be applied correctly.

Observed

In some cases when hv.renderer('bokeh').theme = 'dark_minimal' is used, the theme bgcolor is not applied correctly.

Here is a table listing all cases, where ✅ means it's fine, and ❌ means the bgcolor is not applied correctly:

Colab VSCode
hv.Image
bk.plotting.show(hv.render(hv.Image))
pn.Row(hv.Image)
pn.Row(hv.render(hv.Image))
pn.Row(hv.Image).save()->Chrome
pn.Row(hv.render(hv.Image)).save()->Chrome

It seems like the hv.render is producing the problem, as well as the odd case of holoviews & panel integration on VSCode.

Reproduction

I reproduced this error in a Colab notebook.

Here is a minimal code reproduction:

import holoviews as hv
import panel as pn
import numpy as np
from bokeh.plotting import show
from bokeh.io import output_notebook

def extension():
  hv.extension("bokeh")
  pn.extension()
  output_notebook()

ls = np.linspace(0, 10, 200)
xx, yy = np.meshgrid(ls, ls)
xy = np.sin(xx)*np.cos(yy)

hv.renderer('bokeh').theme = 'dark_minimal'
def dark_hv():
    return hv.Image(xy)
def dark_bk():
    return hv.render(dark_hv())
def dark_hv_pn():
    return pn.Row(dark_hv())
def dark_bk_pn():
    return pn.Row(dark_bk())

# Cell 1: Good
extension()
dark_hv()

# Cell 2: Wrong bgcolor
extension()
show(dark_bk())

# Cell 3: Good on Colab, Wrong bgcolor on VSCode
extension()
dark_hv_pn()

# Cell 4: Wrong bgcolor
extension()
dark_bk_pn()

# Cell 5
dark_bk_pn().save('dark_bk_pn.html')  # Wrong bgcolor
dark_hv_pn().save('dark_hv_pn.html')  # Good

I actually managed to bypass this issue in WaloViz with a custom holoviews hook, maybe it'll help with the investigation.

Screenshots

Good

good

Wrong bgcolor

bad

Summary

  • I may be interested in making a pull request to address this

Not gonna lie I'm a little out of my depth here, and I am not eager to dive in.
But if you can point out the possible causes for this issue and outline the solution I can help you out with the PR.

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