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.Bars with more than one kdim randomly generates incorrect x-ticks in some cases (matplotlib backend) #6231

Closed
1 task
sztal opened this issue May 14, 2024 · 3 comments · Fixed by #6145
Closed
1 task
Labels
type: bug Something isn't correct or isn't working

Comments

@sztal
Copy link

sztal commented May 14, 2024

As in the title

ALL software version info

(this library, plus any other relevant software, e.g. bokeh, python, notebook, OS, browser, etc)

  • python=3.11
  • holoviews=1.18.3
  • pandas=2.2.2

Description of expected behavior and the observed behavior

hv.Bars should display x-tick values correctly in all cases instead of making some random errors from time to time in a way which is completely unpredictable.

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

import json
import pandas as pd
import holoviews as hv

hv.extension("matplotlib", logo=False)

json1 = '{"Pet":{"0":"Cat","1":"Cat","2":"Dog","3":"Dog","4":"Hamster","5":"Hamster","6":"Rabbit","7":"Rabbit"},"Gender":{"0":"Female","1":"Male","2":"Female","3":"Male","4":"Female","5":"Male","6":"Female","7":"Male"},"Count":{"0":26,"1":21,"2":36,"3":24,"4":27,"5":34,"6":39,"7":39}}'

json2 = '{"community":{"0":"Concerned","1":"Concerned","2":"Concerned","3":"Informants","4":"Informants"},"stance":{"0":"Dystopia","1":"Pragmatic","2":"Protect","3":"Dystopia","4":"Pragmatic"},"len":{"0":25,"1":41,"2":30,"3":1,"4":56}}'

df1 = pd.DataFrame(json.loads(json1))
df2 = pd.DataFrame(json.loads(json2))

For df1 it works.

hv.Bars(df1, kdims=["Pet", "Gender"])

But for df2 it does not work correctly for some mysterious reasons. Note that the lower values for x-ticks are incorrect (both groups are labelled as "Pragmatic" which is a value of stance variable not community) and display one of the levels of stance variable instead of displaying values of community column (`"Concerned" and "Informants").

hv.Bars(df2, kdims=["community", "stance"])

Please explain to me what is going on here, because it is extremely confusing. I really want to love holoviews because it has a lot of killer features, but sometimes it behaves in so cryptic unpredicable ways that makes it really painful to work with it.

Stack traceback and/or browser JavaScript console output

Screenshots or screencasts of the bug in action

  • I may be interested in making a pull request to address this
@hoxbro
Copy link
Member

hoxbro commented May 14, 2024

If I understand you correctly, this is fixed in #6145 (not yet merged):

 Screenshot 2024-05-14 14 09 18

Current behavior:
 Screenshot 2024-05-14 14 10 01

@sztal
Copy link
Author

sztal commented May 14, 2024

Great, thanks, I hope this will solve the issue. However, I still do not understand what makes any of the axes continuous? The two grouping variables are clearly discrete.

@hoxbro
Copy link
Member

hoxbro commented May 14, 2024

The bug was discovered and fixed in the PR. So, it is not directly related to the title.

See https://github.com/holoviz/holoviews/pull/6145/files#r1589356958

@hoxbro hoxbro added the type: bug Something isn't correct or isn't working label May 14, 2024
@hoxbro hoxbro linked a pull request May 14, 2024 that will close this issue
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