在尝试在 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")
最佳答案
子包是style
,而不是styles
。该文档可以找到 here 。所以使用
import matplotlib.pyplot as plt
plt.style.use('ggplot')
关于python - matplotlib 缺少样式模块?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27731115/