简体   繁体   中英

Python unable to locate mplstyle file in config folder

I want to add my custom.mplstyle to matplotlib. However,

mpl.get_configdir()

returns

/home/user/.config/matplotlib

In this folder I put the file

custom.mplstyle

However, when running Python I get

import matplotlib.pyplot as plt
plt.style.available
['Solarize_Light2', '_classic_test_patch', 'bmh', 'classic', 'dark_background',
 'fast', ..., 'seaborn-talk', 'seaborn-ticks', 'seaborn-white', 'tableau-lorblind10']

but not

'custom'

When running

plt.style.use('custom')

I get

FileNotFoundError: [Errno 2] No such file or directory: 'custom'

If you are specifying a file, you need to give the whole path (absolute or relative) and name. Eg

plt.style.use('../custom.mplstyle')

In the config folder it is in the stylelib subfolder. Eg

/home/user/.config/matplotlib/stylelib

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM