Skip to content

Clean up base matplotlib namespace #2052

Closed

Description

@efiring
import matplotlib
print "\n".join(dir(matplotlib))

yields

RcParams
Verbose
__builtins__
__doc__
__file__
__name__
__package__
__path__
__version__
__version__numpy__
_create_tmp_config_dir
_deprecated_ignore_map
_deprecated_map
_get_configdir
_get_data_path
_get_data_path_cached
_get_home
_havedate
_is_writable_dir
_python24
_required
_use_error_msg
ascii
byte2str
cbook
checkdep_dvipng
checkdep_ghostscript
checkdep_inkscape
checkdep_pdftops
checkdep_ps_distiller
checkdep_tex
checkdep_usetex
checkdep_xmllint
colors
compare_versions
compat
converter
dateutil
default
defaultParams
default_test_modules
distutils
expected_version
fontconfig_pattern
found_version
get_backend
get_configdir
get_data_path
get_example_data
get_home
get_py2exe_datafiles
interactive
is_interactive
is_string_like
key
major
matplotlib_fname
minor1
minor2
numpy
os
print_function
pyparsing
rc
rcParams
rcParamsDefault
rcParamsOrig
rc_context
rc_file
rc_file_defaults
rc_params
rc_params_from_file
rcdefaults
rcsetup
re
s
shutil
subprocess
sys
tempfile
test
tk_window_focus
tmp
use
validate_backend
validate_toolbar
verbose
warnings
x

This is a mess; from the user's standpoint there are some useful things in there, but they are hard to identify among all the detritus from the startup process. And then there is the bewildering rc conglomeration. Maybe that should be treated separately.

I'm not sure whether cleaning this up requires one or more MEPs, but it probably does require some strategic thinking, so I am starting this with a MEP tag.

As a first shot, maybe all that is required is a bunch of del commands sprinkled throughout init.py. Or, every variable and module that needs to be deleted could be given a unique prefix, or added to a list, and then all could be deleted at the end.

Alternatively, leading underscores could be used aggressively so that at least when using ipython tab completion, only names that are intended to be part of the public API would appear.

Activity

  1. pelson commented on May 23, 2013

    @pelson
    Member

    To remove most of the rc type objects we can create a config module and simply expose the RcParams instance rcParams to matplotlib/__init__.py. We might consider adding the context manager capabilities to the RcParams class itself (with a method, rather than overriding __call__ or some other such loaded behaviour).

    As you say, much of the rest looks like it could simply be deleted.

  2. pelson commented on May 23, 2013

    @pelson
    Member

    I don't necessarily think we need a MEP for this - thanks to @mdboom's deprecate wrapper it'd be a pretty quick PR to deprecate most of the unnecessary stuff - is feasible to get this into v1.3 and actually removed in v1.4+.

  3. dpsanders commented on Jul 20, 2013

    @dpsanders

    The name rcParams is terrible -- it reeks of 1970s UNIX! What about mpl_parameters, or just parameters?
    Easy enough to introduce the new name and deprecate the old without breaking anything.

  4. added this to the milestone on Aug 17, 2014
  5. petehuang commented on Dec 29, 2016

    @petehuang
    Contributor

    Namespace is still stuffy. For clarity, the deprecate functionality is here https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/cbook.py. You can see examples of usage in commit 8364f87

  6. modified the milestones: , on Oct 3, 2017
  7. github-actions commented on Mar 1, 2023

    @github-actions

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

  8. added
    keepItems to be ignored by the “Stale” Github Action
    and removed
    status: inactiveMarked by the “Stale” Github Action
    on Mar 1, 2023
  9. timhoffm commented on Mar 1, 2023

    @timhoffm
    Member

    While we have made some progress, there's still things we may want to clean up.

  10. timhoffm commented on Sep 15, 2025

    @timhoffm
    Member

    More cleanup done in #28728.

    I think the only left cleanup is the set of *rc functions, but that would be part of a redesign and we don't need to keep this issue open for that.

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

    API: changesChanges to the public API, typically requiring deprecation.MEP: MEP neededkeepItems to be ignored by the “Stale” Github Action

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions