How to find matplotlib style name?

Viewed 3555

Is it possible to know the name of the current matplotlib style? I know that I can get the list of all available styles using plt.style.available, but what I want is the possibility of getting the name of the style currently in use. I am working in the ipython console of spyder, python 3.5, but I would be surprised if answer to this would depend on my working environment :)

2 Answers

You can also sort available styles according to the number of matched parameters with the current one as follows:

r = [ ( style,
    round(sum([1 for key in plt.style.library[style] if plt.rcParams[key] == plt.style.library[style][key]]) \
    /len(plt.style.library[style]),2)
  )
  for style in plt.style.available
]
sorted(r,key=lambda x: x[1], reverse=True)
Related