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

Grouped Bars not rendering correctly #5726

Closed
philippjfr opened this issue May 23, 2023 · 4 comments
Closed

Grouped Bars not rendering correctly #5726

philippjfr opened this issue May 23, 2023 · 4 comments
Labels
tag: backend: bokeh type: bug Something isn't correct or isn't working upstream
Milestone

Comments

@philippjfr
Copy link
Member

philippjfr commented May 23, 2023

Noticed this in hvplot documentation and also on the latest dev build:

http://dev.holoviews.org/reference/elements/bokeh/Bars.html

Screen Shot 2023-05-23 at 17 54 27
@philippjfr philippjfr added the TRIAGE Needs triaging label May 23, 2023
@hoxbro hoxbro added type: bug Something isn't correct or isn't working tag: backend: bokeh and removed TRIAGE Needs triaging labels May 23, 2023
@hoxbro hoxbro added this to the 1.16.1 milestone May 26, 2023
@hoxbro
Copy link
Member

hoxbro commented May 26, 2023

This is a Bokeh problem with ObjectNDArray.

# This is mostly code from webpage.
import holoviews as hv
import numpy as np
import pandas as pd

hv.extension("bokeh")
samples = 100

pets = ["Dog"]
genders = ["Female", "Male"]

pets_sample = np.random.choice(pets, samples)
gender_sample = np.random.choice(genders, samples)
count = np.random.randint(1, 5, size=samples)
df = pd.DataFrame({"Pets": pets_sample, "Gender": gender_sample, "Count": count})
bars = hv.Bars(df, kdims=["Pets", "Gender"]).aggregate(function=np.sum)

Converting the code to Bokeh,

from bokeh.io import show
from bokeh.models import Row

bp_org = hv.render(bars)
bp_fix = hv.render(bars)
data = bp_fix.renderers[0].data_source.data
data["xoffsets"] = data["xoffsets"].tolist()

show(Row(bp_org, bp_fix))

image

@nicolaskruchten
Copy link

Is the same thing happening for box plots or is that a different issue? https://holoviews.org/gallery/demos/bokeh/boxplot_chart.html today looks like this, whereas I would expect the boxes to be non-overlapping:

image

@hoxbro
Copy link
Member

hoxbro commented Jun 2, 2023

This is the same issue. If you need to use this functionality right now, you can use the following hook:

def dtype_fix_hook(plot, element):
    renderers = plot.handles["plot"].renderers
    for renderer in renderers:
        data = renderer.data_source.data
        for k, v in data.items():
            if hasattr(v, "dtype") and v.dtype.kind == "U":
                data[k] = v.tolist()

boxwhisker.opts(hooks=[dtype_fix_hook])

image

@hoxbro
Copy link
Member

hoxbro commented Jun 16, 2023

I will close the issue as we have a workaround in Holoviews.

https://holoviews.org/reference/elements/bokeh/Bars.html
image

https://holoviews.org/gallery/demos/bokeh/boxplot_chart.html
image

@hoxbro hoxbro closed this as completed Jun 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tag: backend: bokeh type: bug Something isn't correct or isn't working upstream
Projects
None yet
Development

No branches or pull requests

3 participants