4

i'm trying to use a custom matplotlib-style

But it does not work:

As mentioned here:

http://matplotlib.org/users/style_sheets.html

i tried the following:

import matplotlib.pyplot as plt
print plt.style.available

matplotlib.pyplot works fine. But it keeps saying that style is not defined.

>>> import matplotlib.pyplot as plt
>>> print plt.style.available
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'style'

What is the solution?

It is Mac Os X Yosemite and it is installed as Administrator in the default location.

2
  • go into your matplotlib folder in site-packages and check if the style folder exists. (the location of this depends on your operating system and Python installation) Commented Nov 23, 2014 at 8:58
  • i looked in the directory where "matplotlib.__file__" points to and there is no style folder Commented Nov 23, 2014 at 9:48

2 Answers 2

6

Styles are a very recent feature of matplotlib, introduced in version 1.4.

  • If your version of matplotlib is up-to-date then you are suffering from a bug of the installation procedure

  • If your version is older than 1.4 then it is not expected that you have style sheets installed.

To look at your version, do the following (my matplotlib is old...)

>>> import matplotlib
>>> matplotlib.__version__
'1.3.1'
>>>
Sign up to request clarification or add additional context in comments.

Comments

3

If you see

>>> import matplotlib
>>> matplotlib.__version__
'1.3.1'
>>>

And than you should make 1.4.1 or up

do it

sudo pip3 install --upgrade matplotlib

or

sudo pip install --upgrade matplotlib

after update ,you will see as like that

>>> import matplotlib
>>> matplotlib.__version__
'1.5.0'

1 Comment

if running the above gives you an error on OSX. try sudo pip install matplotlib --upgrade --ignore-installed six

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.