Home > front end >  Python unable to locate mplstyle file in config folder
Python unable to locate mplstyle file in config folder

Time:08-11

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'

CodePudding user response:

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

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

In the config folder it is in the stylelib subfolder. E.g.

/home/user/.config/matplotlib/stylelib
  • Related