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

Sort feature for icicle chart #4555

Open
ericsunplus opened this issue Mar 21, 2024 · 0 comments
Open

Sort feature for icicle chart #4555

ericsunplus opened this issue Mar 21, 2024 · 0 comments

Comments

@ericsunplus
Copy link

I want to use icicle chart to show function call stacks, the MWE is as the following

import pandas as pd
import numpy as np
import plotly.express as px

data = np.array(
        [
            ["main", "A-Func", None, 1],
            ["main", "C-Func", "sub1", 1],
            ["main", "C-Func", "sub2", 1],
            ["main", "B-Func", None, 1],
            ["main", "D-func", "sub1", 1],
            ["main", "D-func", "sub2", 1],
            ["main", "D-func", "sub3", 1],
        ]
        )

df = pd.DataFrame(data, columns = ['Level0', 'Level1', 'Level2', 'Weight'])
fig = px.icicle(df, path=['Level0', 'Level1', 'Level2'], values='Weight')
fig.update_traces(root_color="lightblue")
fig.show()

This is yielding a graph sorted by both Weight and Name

enter image description here

If I added sort parameter

fig.update_traces(root_color="lightblue", sort=False)

The weight is not sorted, however the name are still sorted

enter image description here

What I want to achieve is the nature order of these function calls as I create the numpy object

main
  |
  +--- A-Func
  |
  +--- C-Func
  |     |
  |     +--- sub1
  |     |
  |     +--- sub2
  |
  +--- B-Func
  |
  +--- D-Func
        |
        +--- sub1
        |
        +--- sub2
        |
        +--- sub3

Is there some option I can use to achieve this?

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