matplotlib缺少样式模块?

时间:2015-01-01 13:13:29

标签: python graph matplotlib

尝试设置"样式" matplotlib中的模块我得到如下的AttributeError:

import matplotlib.pyplot as plt
plt.styles.use("ggplot")

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    plt.styles.use("ggplot")
AttributeError: 'module' object has no attribute 'styles'

为什么?我该如何解决? 我正在使用python 3 64位

编辑: 我使用

得到了同样的错误
plt.style.use("ggplot")

1 个答案:

答案 0 :(得分:2)

子包是style,而不是styles。可以找到文档here。所以使用

import matplotlib.pyplot as plt
plt.style.use('ggplot')