def _rc_context(rcparams):
    """
    Context manager that temporarily overrides the pyplot rcParams.
    """
    deprecated = ['text.latex.unicode', 'examples.directory']
    old_rcparams = {k: mpl.rcParams[k] for k in mpl.rcParams.keys()
                    if mpl_version < '3.0' or k not in deprecated}
    mpl.rcParams.clear()
    mpl.rcParams.update(dict(old_rcparams, **rcparams))
    try:
        yield
    finally:
        mpl.rcParams.clear()
        mpl.rcParams.update(old_rcparams)
Context manager that temporarily overrides the pyplot rcParams.