Skip to content

"Error: local variable 'xdata' referenced before assignment" in legend_handler.py #6921

Closed

Description

@pfaion

Hi everyone,
I made a stupid typo and generated a legend for my plot with half a numpoint

plt.legend(numpoints = 0.5)

which obviously makes no sense. But finding the error took some time due to the stupid error message and the original issue not being handles correctly here:

https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/legend_handler.py#L151

If you check for being an integer in the if-statement and throw a more readable error if not (e.g. "Number of points has to be an integer", or similar) that would be great.

Cheers
Patrick

Activity

  1. added this to the milestone on Aug 13, 2016
  2. added
    Difficulty: Easyhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issues
    on Aug 13, 2016
  3. tacaswell commented on Aug 13, 2016

    @tacaswell
    Member

    @pfaion would you be willing to take a crack at that? You seem to have a good idea of what needs to be done.

  4. phobson commented on Apr 18, 2017

    @phobson
    Member

    closed via #8478

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty: Easyhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issues

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions