def set_style(style, mpl=False, **kwargs):
    """
    If mpl is False accept either style name or a TStyle instance.
    If mpl is True accept either style name or a matplotlib.rcParams-like
    dictionary
    """
    if mpl:
        import matplotlib as mpl

        style_dictionary = {}
        if isinstance(style, string_types):
            style_dictionary = get_style(style, mpl=True, **kwargs)
            log.info("using matplotlib style '{0}'".format(style))
        elif isinstance(style, dict):
            style_dictionary = style
            log.info("using user-defined matplotlib style")
        else:
            raise TypeError("style must be a matplotlib style name or dict")
        for k, v in style_dictionary.items():
            mpl.rcParams[k] = v
    else:
        if isinstance(style, string_types):
            style = get_style(style, **kwargs)
        log.info("using ROOT style '{0}'".format(style.GetName()))
        style.cd()
If mpl is False accept either style name or a TStyle instance.
    If mpl is True accept either style name or a matplotlib.rcParams-like
    dictionary