I'm trying to create my own matplotlib stylesheets but Python doesn't detect them. Even worse: when I moved one of the five default stylesheets (ggplot.mplstyle), Python kept reporting it was availabe.
I tried to reload the entire module but to no avail:
import matplotlib
reload(matplotlib)
from matplotlib import style as style
plt = matplotlib.pyplot
print plt.style.available
just keeps returning
[u'dark_background', u'bmh', u'grayscale', u'ggplot', u'fivethirtyeight']
How can I force a "refresh" of these styles?
P.s. I'm not a Python expert.
Another way to change the visual appearance of plots is to set the rcParams in a so-called style sheet and import that style sheet with matplotlib. style. use . In this way you can switch easily between different styles by simply changing the imported style sheet.
Another example of a style is from fivethirtyeight: style. use('fivethirtyeight') You can see all of the available styles you currently have by doing: print(plt. style.
Changing the Defaults: rcParams Each time Matplotlib loads, it defines a runtime configuration (rc) containing the default styles for every plot element you create. This configuration can be adjusted at any time using the plt. rc convenience routine.
Just in case someone else stumbles on this post, this issue was reported and resolved here:
https://github.com/matplotlib/matplotlib/issues/3601
Basically, the style library looks for files in a subdirectory of the matplotlib config directory. On linux/osx system, this would be something like ~/.matplotlib/stylelib/<my-custom-style>.mplstyle
.
Also, as @tcaswell suggested in comments, loading is done at import time, so style files added or edited after import will not work without a call to plt.style.reload_library()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With