Skip to content

RcParams deprecation warnings in matplotlib <3.1.0 #196

Closed

Description

@pratiman-91

Description

First of all, thank you for creating the library. I was frustrated with writing long codes just to generate a simple plot.
This library came to rescue.

MatplotlibDeprecationWarning:
The examples.directory rcparam was deprecated in Matplotlib 3.0 and will be removed in 3.2. In the future, examples will be found relative to the 'datapath' directory.
self[key] = other[key]

Steps to reproduce

import proplot as plot

Proplot version

0.6.4

Activity

  1. lukelbd commented on Jun 21, 2020

    @lukelbd
    Collaborator

    Glad you find it useful!

    I don't think this issue is specific to proplot -- do you get the warning message by just running import matplotlib? It appears you have a matplotlibrc or .proplotrc file with the deprecated parameter name 'examples.directory'.

    Check out the contents of your local matplotlibrc to see if it has an uncommented examples.directory line. You can find the location of this file by running the following:

    import matplotlib as mpl
    filename = mpl.matplotlib_fname()
    print(filename)

    You should also check the ~/.proplotrc file for an uncommented examples.directory line.

    This matplotlib page gives some useful info on how matplotlib "rcparams" work.

  2. pratiman-91 commented on Jun 22, 2020

    @pratiman-91
    ContributorAuthor

    do you get the warning message by just running import matplotlib?
    No. Everything works just fine. No warnings at all.

    I found the problem, it is related to _collections_abc.py. Check this link.

    I do not know how proplot and _collections_abc.py are related. \

    Since, it is just a warning so we can ignore it for the time being.

  3. lacstorm commented on Jun 22, 2020

    @lacstorm

    Maybe you could fix this by updating matplotlib to the latest version.

  4. lukelbd commented on Jun 22, 2020

    @lukelbd
    Collaborator

    @pratiman-91

    Since, it is just a warning so we can ignore it for the time being.

    Sounds good.

    do you get the warning message by just running import matplotlib?
    No. Everything works just fine. No warnings at all.

    When you get the time, could you post the resulting error message when you run the following code?

    import matplotlib as mpl
    import warnings
    warnings.simplefilter('error', mpl.MatplotlibDeprecationWarning)
    import proplot  # should trigger error and print full traceback

    @lacstorm

    Maybe you could fix this by updating matplotlib to the latest version.

    Yep this also may fix it, but since import matplotlib does not trigger the error, sounds like it's a proplot issue.

  5. lacstorm commented on Jun 22, 2020

    @lacstorm

    @lukelbd
    When I use matplotlib v3.1.3, I got the same warning. But this just disappear when I update matplotlib to the newest v 3.2.2.

  6. pratiman-91 commented on Jun 22, 2020

    @pratiman-91
    ContributorAuthor

    @lukelbd
    When you get the time, could you post the resulting error message when you run the following code?

    import matplotlib as mpl
    import warnings
    warnings.simplefilter('error', mpl.MatplotlibDeprecationWarning)
    import proplot  # should trigger error and print full traceback
    

    Output

    Traceback (most recent call last):
    
      File "<ipython-input-1-b76332bb521a>", line 4, in <module>
        import proplot  # should trigger error and print full traceback
    
      File "C:\Users\Ghost\miniconda3\lib\site-packages\proplot\__init__.py", line 8, in <module>
        from .config import *  # noqa: F401 F403
    
      File "C:\Users\Ghost\miniconda3\lib\site-packages\proplot\config.py", line 1571, in <module>
        _ = RcConfigurator()
    
      File "C:\Users\Ghost\miniconda3\lib\site-packages\proplot\config.py", line 240, in __init__
        self.reset(local=local, user=user, default=default)
    
      File "C:\Users\Ghost\miniconda3\lib\site-packages\proplot\config.py", line 805, in reset
        rc_matplotlib.update(_get_style_dicts('original', filter=False))
    
      File "C:\Users\Ghost\miniconda3\lib\_collections_abc.py", line 841, in update
        self[key] = other[key]
    
      File "C:\Users\Ghost\miniconda3\lib\site-packages\matplotlib\__init__.py", line 794, in __setitem__
        "3.0", name=key, obj_type="rcparam", addendum="In the "
    
      File "C:\Users\Ghost\miniconda3\lib\site-packages\matplotlib\cbook\deprecation.py", line 114, in warn_deprecated
        _warn_external(warning)
    
      File "C:\Users\Ghost\miniconda3\lib\site-packages\matplotlib\cbook\__init__.py", line 2078, in _warn_external
        warnings.warn(message, category, stacklevel)
    
    MatplotlibDeprecationWarning: 
    The examples.directory rcparam was deprecated in Matplotlib 3.0 and will be removed in 3.2. In the future, examples will be found relative to the 'datapath' directory.
    

    @lacstorm

    When I use matplotlib v3.1.3, I got the same warning. But this just disappear when I update matplotlib to the newest v 3.2.2.

    Yes! It solves the problem.

  7. lukelbd commented on Jun 22, 2020

    @lukelbd
    Collaborator

    @pratiman-91

    Glad the upgrade fixed it! Thanks for posting the traceback, I'll try to fix that at some point in the future (want to keep proplot compatible with earlier matplotlib versions)

  8. pratiman-91 commented on Jun 22, 2020

    @pratiman-91
    ContributorAuthor

    Thanks for your help!

  9. pabloconrat commented on Jun 27, 2021

    @pabloconrat

    Hi,
    thank you very much for your work with this package also from my side! I'm posting this here because it might be related as I also got the same deprecation warning under matplotlib version 3.1.0. Now that I have updated matplotlib to the latest version (3.4.2) I get the following error message:

    ---------------------------------------------------------------------------
    AttributeError                            Traceback (most recent call last)
    <ipython-input-1-4f428cb88cea> in <module>
          1 import matplotlib.pyplot as plt
    ----> 2 import proplot as plot
    
    ~/.local/lib/python3.7/site-packages/proplot/__init__.py in <module>
          6 # In the future we will not import the class names
          7 import pkg_resources as _pkg
    ----> 8 from .config import *  # noqa: F401 F403
          9 from .internals import timers
         10 with timers._benchmark('imports'):
    
    ~/.local/lib/python3.7/site-packages/proplot/config.py in <module>
       1569 
       1570 with timers._benchmark('rc'):
    -> 1571     _ = RcConfigurator()
       1572 
       1573 #: Instance of 'RcConfigurator'. This is used to change global settings.
    
    ~/.local/lib/python3.7/site-packages/proplot/config.py in __init__(self, local, user, default)
        238         """
        239         self._context = []
    --> 240         self.reset(local=local, user=user, default=default)
        241 
        242     def __enter__(self):
    
    ~/.local/lib/python3.7/site-packages/proplot/config.py in reset(self, local, user, default)
        803         # NOTE: see _remove_blacklisted_style_params bugfix
        804         if default:
    --> 805             rc_matplotlib.update(_get_style_dicts('original', filter=False))
        806             rc_matplotlib.update(rcsetup._rc_matplotlib_default)
        807             rc_proplot.update(rcsetup._rc_proplot_default)
    
    ~/.local/lib/python3.7/site-packages/proplot/config.py in _get_style_dicts(style, infer, filter)
       1151 
       1152     # Always apply the default style *first* so styles are rigid
    -> 1153     kw_matplotlib = _get_default_dict()
       1154     if style == 'default' or style is mpl.rcParamsDefault:
       1155         return kw_matplotlib
    
    ~/.local/lib/python3.7/site-packages/proplot/config.py in _get_default_dict()
       1093     # filter them out. Beware if hidden attribute changes.
       1094     rcdict = _get_filtered_dict(mpl.rcParamsDefault, warn=False)
    -> 1095     with cbook._suppress_matplotlib_deprecation_warning():
       1096         rcdict = dict(RcParams(rcdict))
       1097     for attr in ('_deprecated_remain_as_none', '_deprecated_set'):
    
    AttributeError: module 'matplotlib.cbook' has no attribute '_suppress_matplotlib_deprecation_warning'
    

    after importing both matplotlib.pyplot and proplot:

    import matplotlib.pyplot as plt
    import proplot as plot
    

    I'm using ProPlot's version 0.6.4.

  10. pratiman-91 commented on Jun 27, 2021

    @pratiman-91
    ContributorAuthor

    @pabloconrat Currently, the latest version of matplotlib (3.4.2) breaks the proplot. See #248 for more details. You can downgrade your matplotlib to 3.3.4. This should work.

  11. pabloconrat commented on Jun 29, 2021

    @pabloconrat

    @pratiman-91 I tried that but that didn't do the trick. Going further back works though. My problem is that other projects require the new Matplotlib version but thank's for pointing out that issue and great to see that it's already on the agenda :)

  12. lukelbd commented on Jun 29, 2021

    @lukelbd
    Collaborator

    The 3.3 and 3.4 compatibility issues are now fixed by #251 (also see #248). You can upgrade to the "development" branch that has these changes using pip install git+https://github.com/lukelbd/proplot.git. Though will try to push a stable version 0.7 in the next few days.

  13. changed the title [-]Matplotlib Deprecation Warning: rcparam[/-] [+]RcParams deprecation warnings in matplotlib <3.1.0[/+] on Jun 29, 2021
  14. pabloconrat commented on Jul 6, 2021

    @pabloconrat

    Thanks so much!

  15. lukelbd commented on Jan 24, 2022

    @lukelbd
    Collaborator

    This was finally closed by f0230f1. Importing proplot will no longer trigger a deprecation warning (have been working on more robust testing / dependency management).

  16. lukelbd commented on Jan 24, 2022

    @lukelbd
    Collaborator

    There was also an issue preventing basic proplot usage in matplotlib < 3.1.2 due to rcsetup.validate_fontweight not being defined. Fixed this in 1d2d05b.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions