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

NdOverlay messing up legend item order #5503

Open
openSourcerer9000 opened this issue Oct 31, 2022 · 4 comments
Open

NdOverlay messing up legend item order #5503

openSourcerer9000 opened this issue Oct 31, 2022 · 4 comments

Comments

@openSourcerer9000
Copy link

openSourcerer9000 commented Oct 31, 2022

Having the same issue as another user (#4082),

import numpy as np
import holoviews as hv
from collections import OrderedDict

hv.extension("plotly")
# hv.extension("bokeh")

data = OrderedDict(zip(['one','two','three','four','five'],
    [hv.Curve(np.random.rand(400)-i) for i in range(5)]))

hv.NdOverlay(data).opts(show_legend=True,width=1200)

with plotly backend:
image
bokeh backend:
image

It reorders to five, four, one, three, two for some reason, which for obvious reasons can make a plot confusing for a reader. Is there a workaround for this? Thanks

hv version 1.15.1

@openSourcerer9000
Copy link
Author

So it looks like this is alphabetical order, is there a way to override this behavior?

@jbednar
Copy link
Member

jbednar commented Nov 1, 2022

See holoviz/hvplot#551 ; it's a bit of a mess!

@openSourcerer9000
Copy link
Author

openSourcerer9000 commented Nov 1, 2022

I imagine there's just a sort or sort_values somewhere in the code that sorts legend items alphabetically, maybe this one. Finding it and removing it should solve the issue

column = column.sort_values()

@jbednar
Copy link
Member

jbednar commented Nov 1, 2022

That's surely part of it, but different Elements apparently currently act differently (see examples in holoviz/hvplot#551), and Bokeh also does sorting. I think sorting is a useful thing to support as an option, but letting the user have complete control over the order is also important. I'm not sure how best to achieve that, and in any case we should document how it's achieved. PRs welcome!

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

2 participants