'How to set path to matplotlib custom style?

As per matplotlib documentation:

"You can create custom styles and use them by calling style.use with the path or URL to the style sheet."

I tried:

plt.style.use('/usr/share/mygraph/mystyle.mplstyle')

but it is returning:

ValueError: '/usr/share/mygraph/mystyle.mplstyle' not found in the style library and input is not a valid URL or path. See `style.available` for list of available styles.

Could someone please help me on how to set the path right?

Is there is any other way how to achieve this?

I would like to distribute my custom style in rpm package so it would be tricky to put it in user's home dir.

Setting "MPLCONFIGDIR" environment variable would also work but I would like to avoid this.

Thanks for your help!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ EDIT:

In my impetuosity I forgot to copy the file there. The output error about not valid URL confused me so I thought the whole path is not valid and focused on that. Shame on me!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source