Python matplotlib.get_configdir() Examples

The following are 4 code examples for showing how to use matplotlib.get_configdir(). 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: SciencePlots   Author: garrettj403   File: setup.py    License: MIT License 6 votes vote down vote up
def install_styles():
    
    # Find all style files
    stylefiles = glob.glob('styles/**/*.mplstyle', recursive=True)

    # Find stylelib directory (where the *.mplstyle files go)
    mpl_stylelib_dir = os.path.join(matplotlib.get_configdir() ,"stylelib")
    if not os.path.exists(mpl_stylelib_dir):
        os.makedirs(mpl_stylelib_dir)

    # Copy files over
    print("Installing styles into", mpl_stylelib_dir)
    for stylefile in stylefiles:
        print(os.path.basename(stylefile))
        shutil.copy(
            stylefile, 
            os.path.join(mpl_stylelib_dir, os.path.basename(stylefile))) 
Example 2
Project: sample-factory   Author: alex-petrenko   File: plot_utils.py    License: MIT License 6 votes vote down vote up
def copy_plot_themes():
    stylelib_path = os.path.join(matplotlib.get_configdir(), 'stylelib')
    curr_dir = os.path.dirname(os.path.abspath(__file__))
    file_list = glob.glob(os.path.join(curr_dir, '*.mplstyle'))

    try:
        if not os.path.exists(stylelib_path):
            os.makedirs(stylelib_path)
        for f in file_list:
            fname = os.path.basename(f)
            shutil.copy2(f, os.path.join(stylelib_path, fname))
        print('Themes copied to %s' % stylelib_path)
    except:
        print(
            'An error occured! Try to manually copy the *.mplstyle files. E.g.:\nmkdir -p %s && cp *.mplstyle %s' %
            (stylelib_path, stylelib_path),
        ) 
Example 3
Project: mplhep   Author: scikit-hep   File: tools.py    License: MIT License 5 votes vote down vote up
def hardcopy_styles():
    path = os.path.abspath(__file__)
    pkg_dir = "/" + "/".join(path.split("/")[:-1])
    os.system(
        "cp -r {}/stylelib/ ".format(pkg_dir) + os.path.join(mpl.get_configdir() + "/")
    ) 
Example 4
Project: ray-optics   Author: mjhoptics   File: styledfigure.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def copy_styles():
    """Copy rayoptics mpl styles to user's mpl_config dir."""
    pth = Path(__file__).resolve().parent
    styles_dir = Path(pth / 'styles')
    mpl_configdir = Path(matplotlib.get_configdir()) / 'stylelib'
    mpl_configdir.mkdir(exist_ok=True)
    for mpl_style in styles_dir.glob('*.mplstyle'):
        copy2(mpl_style, mpl_configdir)