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

Enable sorting groupby dimension values? #1463

Open
maximlt opened this issue Dec 8, 2024 · 0 comments
Open

Enable sorting groupby dimension values? #1463

maximlt opened this issue Dec 8, 2024 · 0 comments

Comments

@maximlt
Copy link
Member

maximlt commented Dec 8, 2024

When setting groupby=..., the values of the dimensions displayed in the select widgets are not sorted by default. The workarounds are:

  1. pre-process the data to sort it
  2. set dynamic=False (default is True): HoloViews will internally instantiate a HoloMap (DynamicMap when dynamic=False) which sorts the values by default (MultiDimensionalMapping.sort is True by default).

When it comes to displaying large datasets, 1. is annoying and 2. is usually not available as setting dynamic=False on a rasterized/datashaded plot is mostly pointless.

Should hvPlot's default behavior be to sort the dimension values (requires holoviz/holoviews#6471)? If so, should we let users disable this? (keywords are easy to add but also come with some drawbacks).

import hvplot.pandas
import pandas as pd

N = 12
df = pd.DataFrame({
    'cat1': ['A', 'A', 'A', 'A', 'C', 'C', 'C', 'C', 'B', 'B', 'B', 'B'],
    'cat2': ['y', 'y', 'x', 'x', 'y', 'y', 'x', 'x','y', 'y', 'x', 'x'],
    'x'  : range(N),
    'y'  : range(N),
})

df.hvplot.scatter('x', 'y', groupby=['cat1', 'cat2'])

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant