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

Unable to reproduce last notebook example #133

Open
masek014 opened this issue Apr 14, 2023 · 2 comments
Open

Unable to reproduce last notebook example #133

masek014 opened this issue Apr 14, 2023 · 2 comments
Assignees

Comments

@masek014
Copy link

Problem

The last example in the example notebook is not reproducing what is shown in the repository. The labels on the dashed lines are incorrect. There is a mismatch between the lines and the label shown on the lines when specifying the lines parameter in labelLines.

Image produced when I run the example:
wrong

It appears this problem is a result of using the labels from the all_labels variable from the ax.get_legend_handles_labels() call on line 130. The for loop at line 199 in core.py assumes that all_labels and all_lines have the same ordering, which may not always be true if the lines parameter is specified.

It looks like the example notebook hasn't been updated in 3 years, so I presume some change to core.py in the meantime has resulted in this issue.

Tentative solution

I was able to fix this by ignoring the all_labels variable and reading the label directly from the line object when iterating through all_lines. This can be done by changing line 200 to the following: label = line.get_label().

However, perhaps there is a reason this is not already the default. I did not test this with every line object in matplotlib, so there could be some objects in matplotlib that do not support the get_label method.

Thanks

Despite this issue, this is a nice package.
I appreciate the work put into it, and I plan on using it :)

@cphyc cphyc self-assigned this Apr 15, 2023
@cphyc
Copy link
Owner

cphyc commented Apr 15, 2023

Oh yep, that looks like a bug! I am quite oversubscribed but I'd be happy to review a pull request should you find time to fix this :)

@cphyc cphyc removed their assignment Apr 15, 2023
@cphyc cphyc self-assigned this May 5, 2023
@cphyc
Copy link
Owner

cphyc commented Jul 11, 2023

So it turns out I don't have much time to track that issue down. This is a new-contributor friendly bug, so please (anyone) feel free to fix!

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

2 participants