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

Using leftLabels / rightLabels #16

Open
Minyall opened this issue Jul 30, 2018 · 4 comments
Open

Using leftLabels / rightLabels #16

Minyall opened this issue Jul 30, 2018 · 4 comments

Comments

@Minyall
Copy link

Minyall commented Jul 30, 2018

This is a great tool you have here - I'd been trying to make a Sankey using Plotly all morning to no avail, but this was relatively straightforward and looks good. However I'm struggling to order the labels for presentation. I have 9 string labels on the left, and seven string labels on the right but I'm not sure what to pass to leftLabels and 'rightLabels` to define the order. I've passed each arg a list of the labels in the order I want, but I get a LabelMismatch error.

I tried sorting my data before running using .sort_values in pandas however that resulted in incorrect output with the wrong values being assigned to the wrong links (despite the values being correctly ordered in the data frame). I don't know if this is actually the result of a miss-ordering of the labels or if the entirety of the visualised data is incorrect.

I also noted what I think is a mistake in the check_data_matches_labels function. I believe it should be if len(labels) > 0:

Essentially I can get an accurate visual now, but it would be great to be able to reorder the data so that both left and right sets of labels are in alphabetical order, and the links adjust to match.

@Minyall
Copy link
Author

Minyall commented Jul 30, 2018

To provide an update, I used the updates from pull request #15 and found the issue resolved so long as I reversed the label lists. So to have the graph display [a,b,c,d] top to bottom I had to feed it [d,c,b,a]. All links between source and target aligned correctly and in general I'm very pleased with the result!

@magerstein
Copy link

magerstein commented Sep 13, 2018

In addition to the bug mentioned above, there is bug in sankey function when checking right labels. Code should read:

# Identify right labels
if len(rightLabels) == 0:
    rightLabels = pd.Series(df.right.unique()).unique()
else:
    check_data_matches_labels(rightLabels, df['right'], 'right')

@Pierre-Sassoulas
Copy link
Contributor

Nice find @magerstein, could you create a pull request in order to get credited for it ?

@xshou1990
Copy link

I was using it and just realized it as well!

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

4 participants