Python matplotlib.get_configdir() Examples

The following are 4 code examples of matplotlib.get_configdir(). 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 also want to check out all available functions/classes of the module matplotlib , or try the search function .
Example #1
Source File: setup.py    From SciencePlots with 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
Source File: plot_utils.py    From sample-factory with 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
Source File: tools.py    From mplhep with 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
Source File: styledfigure.py    From ray-optics with 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)