Python matplotlib.rcParamsDefault() Examples

The following are 18 code examples for showing how to use matplotlib.rcParamsDefault(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module matplotlib , or try the search function .

Example 1
Project: hydrology   Author: Kirubaharan   File: agu_plot.py    License: GNU General Public License v3.0 6 votes vote down vote up
def format_axes(ax):

    for spine in ['top', 'right']:
        ax.spines[spine].set_visible(False)

    for spine in ['left', 'bottom']:
        ax.spines[spine].set_color(SPINE_COLOR)
        ax.spines[spine].set_linewidth(0.5)

    ax.xaxis.set_ticks_position('bottom')
    ax.yaxis.set_ticks_position('left')

    for axis in [ax.xaxis, ax.yaxis]:
        axis.set_tick_params(direction='out', color=SPINE_COLOR)

    return ax


# mpl.rcParams.update(mpl.rcParamsDefault) 
Example 2
Project: GraphicDesignPatternByPython   Author: Relph1119   File: animation.py    License: MIT License 6 votes vote down vote up
def _init_from_registry(cls):
        if sys.platform != 'win32' or rcParams[cls.exec_key] != 'convert':
            return
        import winreg
        for flag in (0, winreg.KEY_WOW64_32KEY, winreg.KEY_WOW64_64KEY):
            try:
                hkey = winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE,
                                        r'Software\Imagemagick\Current',
                                        0, winreg.KEY_QUERY_VALUE | flag)
                binpath = winreg.QueryValueEx(hkey, 'BinPath')[0]
                winreg.CloseKey(hkey)
                break
            except Exception:
                binpath = ''
        if binpath:
            for exe in ('convert.exe', 'magick.exe'):
                path = os.path.join(binpath, exe)
                if os.path.exists(path):
                    binpath = path
                    break
            else:
                binpath = ''
        rcParams[cls.exec_key] = rcParamsDefault[cls.exec_key] = binpath 
Example 3
Project: python3_ios   Author: holzschu   File: animation.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def _init_from_registry(cls):
        if sys.platform != 'win32' or rcParams[cls.exec_key] != 'convert':
            return
        import winreg
        for flag in (0, winreg.KEY_WOW64_32KEY, winreg.KEY_WOW64_64KEY):
            try:
                hkey = winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE,
                                        r'Software\Imagemagick\Current',
                                        0, winreg.KEY_QUERY_VALUE | flag)
                binpath = winreg.QueryValueEx(hkey, 'BinPath')[0]
                winreg.CloseKey(hkey)
                break
            except Exception:
                binpath = ''
        if binpath:
            for exe in ('convert.exe', 'magick.exe'):
                path = os.path.join(binpath, exe)
                if os.path.exists(path):
                    binpath = path
                    break
            else:
                binpath = ''
        rcParams[cls.exec_key] = rcParamsDefault[cls.exec_key] = binpath 
Example 4
Project: coffeegrindsize   Author: jgagneastro   File: animation.py    License: MIT License 6 votes vote down vote up
def _init_from_registry(cls):
        if sys.platform != 'win32' or rcParams[cls.exec_key] != 'convert':
            return
        import winreg
        for flag in (0, winreg.KEY_WOW64_32KEY, winreg.KEY_WOW64_64KEY):
            try:
                hkey = winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE,
                                        r'Software\Imagemagick\Current',
                                        0, winreg.KEY_QUERY_VALUE | flag)
                binpath = winreg.QueryValueEx(hkey, 'BinPath')[0]
                winreg.CloseKey(hkey)
                break
            except Exception:
                binpath = ''
        if binpath:
            for exe in ('convert.exe', 'magick.exe'):
                path = os.path.join(binpath, exe)
                if os.path.exists(path):
                    binpath = path
                    break
            else:
                binpath = ''
        rcParams[cls.exec_key] = rcParamsDefault[cls.exec_key] = binpath 
Example 5
Project: twitter-stock-recommendation   Author: alvarobartt   File: animation.py    License: MIT License 6 votes vote down vote up
def _init_from_registry(cls):
        if sys.platform != 'win32' or rcParams[cls.exec_key] != 'convert':
            return
        from six.moves import winreg
        for flag in (0, winreg.KEY_WOW64_32KEY, winreg.KEY_WOW64_64KEY):
            try:
                hkey = winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE,
                                        'Software\\Imagemagick\\Current',
                                        0, winreg.KEY_QUERY_VALUE | flag)
                binpath = winreg.QueryValueEx(hkey, 'BinPath')[0]
                winreg.CloseKey(hkey)
                binpath += '\\convert.exe'
                break
            except Exception:
                binpath = ''
        rcParams[cls.exec_key] = rcParamsDefault[cls.exec_key] = binpath 
Example 6
Project: scanpy   Author: theislab   File: _rcmod.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def set_rcParams_defaults():
    """Reset `matplotlib.rcParams` to defaults."""
    rcParams.update(matplotlib.rcParamsDefault) 
Example 7
Project: nelpy   Author: nelpy   File: rcmod.py    License: MIT License 5 votes vote down vote up
def reset_defaults():
    """Restore all RC params to default settings."""
    mpl.rcParams.update(mpl.rcParamsDefault) 
Example 8
Project: scvelo   Author: theislab   File: settings.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def set_rcParams_defaults():
    """Reset `matplotlib.rcParams` to defaults."""
    from matplotlib import rcParamsDefault

    rcParams.update(rcParamsDefault)


# ------------------------------------------------------------------------------
# Private global variables & functions
# ------------------------------------------------------------------------------ 
Example 9
Project: dynamo-release   Author: aristoteleo   File: configuration.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def reset_rcParams():
    """Reset `matplotlib.rcParams` to defaults."""
    from matplotlib import rcParamsDefault

    rcParams.update(rcParamsDefault) 
Example 10
Project: Mastering-Elasticsearch-7.0   Author: PacktPublishing   File: core.py    License: MIT License 4 votes vote down vote up
def use(style):
    """Use matplotlib style settings from a style specification.

    The style name of 'default' is reserved for reverting back to
    the default style settings.

    Parameters
    ----------
    style : str, dict, or list
        A style specification. Valid options are:

        +------+-------------------------------------------------------------+
        | str  | The name of a style or a path/URL to a style file. For a    |
        |      | list of available style names, see `style.available`.       |
        +------+-------------------------------------------------------------+
        | dict | Dictionary with valid key/value pairs for                   |
        |      | `matplotlib.rcParams`.                                      |
        +------+-------------------------------------------------------------+
        | list | A list of style specifiers (str or dict) applied from first |
        |      | to last in the list.                                        |
        +------+-------------------------------------------------------------+


    """
    style_alias = {'mpl20': 'default',
                   'mpl15': 'classic'}
    if isinstance(style, str) or hasattr(style, 'keys'):
        # If name is a single str or dict, make it a single element list.
        styles = [style]
    else:
        styles = style

    styles = (style_alias.get(s, s) if isinstance(s, str) else s
              for s in styles)
    for style in styles:
        if not isinstance(style, str):
            _apply_style(style)
        elif style == 'default':
            # Deprecation warnings were already handled when creating
            # rcParamsDefault, no need to reemit them here.
            with cbook._suppress_matplotlib_deprecation_warning():
                _apply_style(rcParamsDefault, warn=False)
        elif style in library:
            _apply_style(library[style])
        else:
            try:
                rc = rc_params_from_file(style, use_default_template=False)
                _apply_style(rc)
            except IOError:
                raise IOError(
                    "{!r} not found in the style library and input is not a "
                    "valid URL or path; see `style.available` for list of "
                    "available styles".format(style)) 
Example 11
Project: GraphicDesignPatternByPython   Author: Relph1119   File: core.py    License: MIT License 4 votes vote down vote up
def use(style):
    """Use matplotlib style settings from a style specification.

    The style name of 'default' is reserved for reverting back to
    the default style settings.

    Parameters
    ----------
    style : str, dict, or list
        A style specification. Valid options are:

        +------+-------------------------------------------------------------+
        | str  | The name of a style or a path/URL to a style file. For a    |
        |      | list of available style names, see `style.available`.       |
        +------+-------------------------------------------------------------+
        | dict | Dictionary with valid key/value pairs for                   |
        |      | `matplotlib.rcParams`.                                      |
        +------+-------------------------------------------------------------+
        | list | A list of style specifiers (str or dict) applied from first |
        |      | to last in the list.                                        |
        +------+-------------------------------------------------------------+


    """
    style_alias = {'mpl20': 'default',
                   'mpl15': 'classic'}
    if isinstance(style, str) or hasattr(style, 'keys'):
        # If name is a single str or dict, make it a single element list.
        styles = [style]
    else:
        styles = style

    styles = (style_alias.get(s, s) if isinstance(s, str) else s
              for s in styles)
    for style in styles:
        if not isinstance(style, str):
            _apply_style(style)
        elif style == 'default':
            # Deprecation warnings were already handled when creating
            # rcParamsDefault, no need to reemit them here.
            with warnings.catch_warnings():
                warnings.simplefilter("ignore", MatplotlibDeprecationWarning)
                _apply_style(rcParamsDefault, warn=False)
        elif style in library:
            _apply_style(library[style])
        else:
            try:
                rc = rc_params_from_file(style, use_default_template=False)
                _apply_style(rc)
            except IOError:
                raise IOError(
                    "{!r} not found in the style library and input is not a "
                    "valid URL or path; see `style.available` for list of "
                    "available styles".format(style)) 
Example 12
Project: GraphicDesignPatternByPython   Author: Relph1119   File: pyplot.py    License: MIT License 4 votes vote down vote up
def switch_backend(newbackend):
    """
    Close all open figures and set the Matplotlib backend.

    The argument is case-insensitive.  Switching to an interactive backend is
    possible only if no event loop for another interactive backend has started.
    Switching to and from non-interactive backends is always possible.

    Parameters
    ----------
    newbackend : str
        The name of the backend to use.
    """
    close("all")

    if newbackend is rcsetup._auto_backend_sentinel:
        for candidate in ["macosx", "qt5agg", "qt4agg", "gtk3agg", "gtk3cairo",
                          "tkagg", "wxagg", "agg", "cairo"]:
            try:
                switch_backend(candidate)
            except ImportError:
                continue
            else:
                rcParamsOrig['backend'] = candidate
                return

    backend_name = (
        newbackend[9:] if newbackend.startswith("module://")
        else "matplotlib.backends.backend_{}".format(newbackend.lower()))

    backend_mod = importlib.import_module(backend_name)
    Backend = type(
        "Backend", (matplotlib.backends._Backend,), vars(backend_mod))
    _log.debug("Loaded backend %s version %s.",
               newbackend, Backend.backend_version)

    required_framework = Backend.required_interactive_framework
    current_framework = \
        matplotlib.backends._get_running_interactive_framework()
    if (current_framework and required_framework
            and current_framework != required_framework):
        raise ImportError(
            "Cannot load backend {!r} which requires the {!r} interactive "
            "framework, as {!r} is currently running".format(
                newbackend, required_framework, current_framework))

    rcParams['backend'] = rcParamsDefault['backend'] = newbackend

    global _backend_mod, new_figure_manager, draw_if_interactive, _show
    _backend_mod = backend_mod
    new_figure_manager = Backend.new_figure_manager
    draw_if_interactive = Backend.draw_if_interactive
    _show = Backend.show

    # Need to keep a global reference to the backend for compatibility reasons.
    # See https://github.com/matplotlib/matplotlib/issues/6092
    matplotlib.backends.backend = newbackend 
Example 13
Project: python3_ios   Author: holzschu   File: core.py    License: BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def use(style):
    """Use matplotlib style settings from a style specification.

    The style name of 'default' is reserved for reverting back to
    the default style settings.

    Parameters
    ----------
    style : str, dict, or list
        A style specification. Valid options are:

        +------+-------------------------------------------------------------+
        | str  | The name of a style or a path/URL to a style file. For a    |
        |      | list of available style names, see `style.available`.       |
        +------+-------------------------------------------------------------+
        | dict | Dictionary with valid key/value pairs for                   |
        |      | `matplotlib.rcParams`.                                      |
        +------+-------------------------------------------------------------+
        | list | A list of style specifiers (str or dict) applied from first |
        |      | to last in the list.                                        |
        +------+-------------------------------------------------------------+


    """
    style_alias = {'mpl20': 'default',
                   'mpl15': 'classic'}
    if isinstance(style, str) or hasattr(style, 'keys'):
        # If name is a single str or dict, make it a single element list.
        styles = [style]
    else:
        styles = style

    styles = (style_alias.get(s, s) if isinstance(s, str) else s
              for s in styles)
    for style in styles:
        if not isinstance(style, str):
            _apply_style(style)
        elif style == 'default':
            # Deprecation warnings were already handled when creating
            # rcParamsDefault, no need to reemit them here.
            with warnings.catch_warnings():
                warnings.simplefilter("ignore", MatplotlibDeprecationWarning)
                _apply_style(rcParamsDefault, warn=False)
        elif style in library:
            _apply_style(library[style])
        else:
            try:
                rc = rc_params_from_file(style, use_default_template=False)
                _apply_style(rc)
            except IOError:
                raise IOError(
                    "{!r} not found in the style library and input is not a "
                    "valid URL or path; see `style.available` for list of "
                    "available styles".format(style)) 
Example 14
Project: python3_ios   Author: holzschu   File: pyplot.py    License: BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def switch_backend(newbackend):
    """
    Close all open figures and set the Matplotlib backend.

    The argument is case-insensitive.  Switching to an interactive backend is
    possible only if no event loop for another interactive backend has started.
    Switching to and from non-interactive backends is always possible.

    Parameters
    ----------
    newbackend : str
        The name of the backend to use.
    """
    close("all")

    if newbackend is rcsetup._auto_backend_sentinel:
        for candidate in ["macosx", "qt5agg", "qt4agg", "gtk3agg", "gtk3cairo",
                          "tkagg", "wxagg", "agg", "cairo"]:
            try:
                switch_backend(candidate)
            except ImportError:
                continue
            else:
                rcParamsOrig['backend'] = candidate
                return

    backend_name = (
        newbackend[9:] if newbackend.startswith("module://")
        else "matplotlib.backends.backend_{}".format(newbackend.lower()))

    backend_mod = importlib.import_module(backend_name)
    Backend = type(
        "Backend", (matplotlib.backends._Backend,), vars(backend_mod))
    _log.debug("Loaded backend %s version %s.",
               newbackend, Backend.backend_version)

    required_framework = Backend.required_interactive_framework
    if required_framework is not None:
        current_framework = \
            matplotlib.backends._get_running_interactive_framework()
        if (current_framework and required_framework
                and current_framework != required_framework):
            raise ImportError(
                "Cannot load backend {!r} which requires the {!r} interactive "
                "framework, as {!r} is currently running".format(
                    newbackend, required_framework, current_framework))

    rcParams['backend'] = rcParamsDefault['backend'] = newbackend

    global _backend_mod, new_figure_manager, draw_if_interactive, _show
    _backend_mod = backend_mod
    new_figure_manager = Backend.new_figure_manager
    draw_if_interactive = Backend.draw_if_interactive
    _show = Backend.show

    # Need to keep a global reference to the backend for compatibility reasons.
    # See https://github.com/matplotlib/matplotlib/issues/6092
    matplotlib.backends.backend = newbackend 
Example 15
Project: coffeegrindsize   Author: jgagneastro   File: core.py    License: MIT License 4 votes vote down vote up
def use(style):
    """Use matplotlib style settings from a style specification.

    The style name of 'default' is reserved for reverting back to
    the default style settings.

    Parameters
    ----------
    style : str, dict, or list
        A style specification. Valid options are:

        +------+-------------------------------------------------------------+
        | str  | The name of a style or a path/URL to a style file. For a    |
        |      | list of available style names, see `style.available`.       |
        +------+-------------------------------------------------------------+
        | dict | Dictionary with valid key/value pairs for                   |
        |      | `matplotlib.rcParams`.                                      |
        +------+-------------------------------------------------------------+
        | list | A list of style specifiers (str or dict) applied from first |
        |      | to last in the list.                                        |
        +------+-------------------------------------------------------------+


    """
    style_alias = {'mpl20': 'default',
                   'mpl15': 'classic'}
    if isinstance(style, str) or hasattr(style, 'keys'):
        # If name is a single str or dict, make it a single element list.
        styles = [style]
    else:
        styles = style

    styles = (style_alias.get(s, s) if isinstance(s, str) else s
              for s in styles)
    for style in styles:
        if not isinstance(style, str):
            _apply_style(style)
        elif style == 'default':
            # Deprecation warnings were already handled when creating
            # rcParamsDefault, no need to reemit them here.
            with warnings.catch_warnings():
                warnings.simplefilter("ignore", MatplotlibDeprecationWarning)
                _apply_style(rcParamsDefault, warn=False)
        elif style in library:
            _apply_style(library[style])
        else:
            try:
                rc = rc_params_from_file(style, use_default_template=False)
                _apply_style(rc)
            except IOError:
                raise IOError(
                    "{!r} not found in the style library and input is not a "
                    "valid URL or path; see `style.available` for list of "
                    "available styles".format(style)) 
Example 16
Project: coffeegrindsize   Author: jgagneastro   File: pyplot.py    License: MIT License 4 votes vote down vote up
def switch_backend(newbackend):
    """
    Close all open figures and set the Matplotlib backend.

    The argument is case-insensitive.  Switching to an interactive backend is
    possible only if no event loop for another interactive backend has started.
    Switching to and from non-interactive backends is always possible.

    Parameters
    ----------
    newbackend : str
        The name of the backend to use.
    """
    close("all")

    if newbackend is rcsetup._auto_backend_sentinel:
        for candidate in ["macosx", "qt5agg", "qt4agg", "gtk3agg", "gtk3cairo",
                          "tkagg", "wxagg", "agg", "cairo"]:
            try:
                switch_backend(candidate)
            except ImportError:
                continue
            else:
                rcParamsOrig['backend'] = candidate
                return

    backend_name = (
        newbackend[9:] if newbackend.startswith("module://")
        else "matplotlib.backends.backend_{}".format(newbackend.lower()))

    backend_mod = importlib.import_module(backend_name)
    Backend = type(
        "Backend", (matplotlib.backends._Backend,), vars(backend_mod))
    _log.debug("Loaded backend %s version %s.",
               newbackend, Backend.backend_version)

    required_framework = Backend.required_interactive_framework
    if required_framework is not None:
        current_framework = \
            matplotlib.backends._get_running_interactive_framework()
        if (current_framework and required_framework
                and current_framework != required_framework):
            raise ImportError(
                "Cannot load backend {!r} which requires the {!r} interactive "
                "framework, as {!r} is currently running".format(
                    newbackend, required_framework, current_framework))

    rcParams['backend'] = rcParamsDefault['backend'] = newbackend

    global _backend_mod, new_figure_manager, draw_if_interactive, _show
    _backend_mod = backend_mod
    new_figure_manager = Backend.new_figure_manager
    draw_if_interactive = Backend.draw_if_interactive
    _show = Backend.show

    # Need to keep a global reference to the backend for compatibility reasons.
    # See https://github.com/matplotlib/matplotlib/issues/6092
    matplotlib.backends.backend = newbackend 
Example 17
Project: CogAlg   Author: boris-kz   File: core.py    License: MIT License 4 votes vote down vote up
def use(style):
    """Use matplotlib style settings from a style specification.

    The style name of 'default' is reserved for reverting back to
    the default style settings.

    Parameters
    ----------
    style : str, dict, or list
        A style specification. Valid options are:

        +------+-------------------------------------------------------------+
        | str  | The name of a style or a path/URL to a style file. For a    |
        |      | list of available style names, see `style.available`.       |
        +------+-------------------------------------------------------------+
        | dict | Dictionary with valid key/value pairs for                   |
        |      | `matplotlib.rcParams`.                                      |
        +------+-------------------------------------------------------------+
        | list | A list of style specifiers (str or dict) applied from first |
        |      | to last in the list.                                        |
        +------+-------------------------------------------------------------+


    """
    style_alias = {'mpl20': 'default',
                   'mpl15': 'classic'}
    if isinstance(style, str) or hasattr(style, 'keys'):
        # If name is a single str or dict, make it a single element list.
        styles = [style]
    else:
        styles = style

    styles = (style_alias.get(s, s) if isinstance(s, str) else s
              for s in styles)
    for style in styles:
        if not isinstance(style, str):
            _apply_style(style)
        elif style == 'default':
            # Deprecation warnings were already handled when creating
            # rcParamsDefault, no need to reemit them here.
            with cbook._suppress_matplotlib_deprecation_warning():
                _apply_style(rcParamsDefault, warn=False)
        elif style in library:
            _apply_style(library[style])
        else:
            try:
                rc = rc_params_from_file(style, use_default_template=False)
                _apply_style(rc)
            except IOError:
                raise IOError(
                    "{!r} not found in the style library and input is not a "
                    "valid URL or path; see `style.available` for list of "
                    "available styles".format(style)) 
Example 18
Project: twitter-stock-recommendation   Author: alvarobartt   File: core.py    License: MIT License 4 votes vote down vote up
def use(style):
    """Use matplotlib style settings from a style specification.

    The style name of 'default' is reserved for reverting back to
    the default style settings.

    Parameters
    ----------
    style : str, dict, or list
        A style specification. Valid options are:

        +------+-------------------------------------------------------------+
        | str  | The name of a style or a path/URL to a style file. For a    |
        |      | list of available style names, see `style.available`.       |
        +------+-------------------------------------------------------------+
        | dict | Dictionary with valid key/value pairs for                   |
        |      | `matplotlib.rcParams`.                                      |
        +------+-------------------------------------------------------------+
        | list | A list of style specifiers (str or dict) applied from first |
        |      | to last in the list.                                        |
        +------+-------------------------------------------------------------+


    """
    style_alias = {'mpl20': 'default',
                   'mpl15': 'classic'}
    if isinstance(style, six.string_types) or hasattr(style, 'keys'):
        # If name is a single str or dict, make it a single element list.
        styles = [style]
    else:
        styles = style

    styles = (style_alias.get(s, s)
              if isinstance(s, six.string_types)
              else s
              for s in styles)
    for style in styles:
        if not isinstance(style, six.string_types):
            _apply_style(style)
        elif style == 'default':
            _apply_style(rcParamsDefault, warn=False)
        elif style in library:
            _apply_style(library[style])
        else:
            try:
                rc = rc_params_from_file(style, use_default_template=False)
                _apply_style(rc)
            except IOError:
                raise IOError(
                    "{!r} not found in the style library and input is not a "
                    "valid URL or path; see `style.available` for list of "
                    "available styles".format(style))