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

handle validate_legend_loc deprecation in matplotlib >=3.3 #33

Merged
merged 24 commits into from
Jan 2, 2021

Conversation

SarthakJariwala
Copy link
Contributor

validate_legend_loc is deprecated in matplotlib 3.3 (to be removed in 3.5) and leaves annoying warnings.

However, the warnings only show up if you update the rcParams using : matplotlib.rcParams.update({"scalebar.location": "lower right}). They don't show up if you do : defaultParams.update({"scalebar.location": "lower right}) and that's likely why it doesn't show up while running tests in matplotlib_scalebar. (Found this out because I kept getting annoying warnings like this while building documentation for my package)

(not sure if not showing deprecation warning in defaultParams.update counts as a bug on matplotlib's end)

Anyways, this PR should fix the deprecation warning. My current take is to simply take the validate_legend_loc implementation from matplotlib. Maybe there's a better way...but this works

@ppinard
Copy link
Owner

ppinard commented Jan 1, 2021

Thanks for the PR. According to the matplotlib deprecation information,

To test whether an rcParam value would be acceptable, one can test e.g. rc = RcParams(); rc[k] = v raises an exception.

It would make more sense to have the following function

def _validate_legend_loc(loc):
    rc = matplotlib.RcParams()
    rc["legend.loc"] = loc

@SarthakJariwala
Copy link
Contributor Author

Thanks! Updated the function.

@ppinard ppinard merged commit 37e0439 into ppinard:master Jan 2, 2021
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

Successfully merging this pull request may close these issues.

2 participants