Skip to content

Make Deprecation Warning in matplotlib more useful #13352

Closed

Description

@HDembinski

Bug report

Sources of deprecation warnings in matplotlib are hard to track down.

Code for reproduction

from matplotlib import pyplot as plt
plt.tick_params(left="False")

Actual outcome

/home/hdembinski/.local/lib/python3.7/site-packages/matplotlib/cbook/__init__.py:424: MatplotlibDeprecationWarning: 
Passing one of 'on', 'true', 'off', 'false' as a boolean is deprecated; use an actual boolean (True/False) instead.
  warn_deprecated("2.2", "Passing one of 'on', 'true', 'off', 'false' as a "

As you can see, there is no indication which line in my client code triggers the warning. If the script is long and not minimal, the origin is difficult to find.

Expected outcome
The deprecation warning should be enhanced with a backtrace of some sort, that allows me to find the call in my script which triggers the warning.

Matplotlib version

  • Matplotlib version: 3.0.2
  • Python version: 3.7.1

Activity

  1. jklymak commented on Feb 3, 2019

    @jklymak
    Member

    Thanks. The deprecation operator was recently improved:

    from matplotlib import pyplot as plt
    fig, ax = plt.subplots()
    print(ax.aname)

    returns the (hopefully) more helpful:

    testdep.py:3: MatplotlibDeprecationWarning:
    The aname attribute was deprecated in Matplotlib 3.1 and will be removed in 3.3.
      print(ax.aname)
    Axes
    

    This change came in #12152 and will be available when 3.1 is released (Feb/Mar timeframe).

    I'll close as fixed.

  2. HDembinski commented on Feb 3, 2019

    @HDembinski
    Author

    Cool, thanks!

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions