10000 [MNT]: Use mpl.rcParams internally · Issue #23680 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
[MNT]: Use mpl.rcParams internally #23680
Closed
@timhoffm

Description

@timhoffm

Summary

Originally mentioned in #16181 (comment)

Don't import rcParams into matplotlib modules directly:

# NO:
from matplotlib import rcParams
...
rcParams[...]

This has the disadvantage that rcParams get into the module namespace and people easily start using that (e.g. from matplotlib import cm; cm.rcParams).

Instead use

# YES:
import matplotlib as mpl
...
mpl.rcParams[...]

While in theory people could still access it via mpl (e.g. cm.mpl.rcParams), this is far more unlikely and good enough for us. - We also don't shield other module imports.

Note: It's also ok to use plt.rcParams if you happen to have pyplot anyway and would have to import mpl. This is in particular true for examples. But most matplotlib modules should not depend on pyplot.

There are many places in the library that need fixing, so it's ok to do this step-by-step.

Related PRs:

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

      0