python - matplotlib 缺少样式模块?

标签 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")

最佳答案

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

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

关于python - matplotlib 缺少样式模块?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27731115/

相关文章:

python - 在 apply 函数内使用定义函数的输入参数

python - IntelliJ 12 Python - 管理.py 任务问题

python - Matplotlib:刻度标签与字体设置不一致(LaTeX 文本示例)

python - 在 python 中绘制 3D 零均值、单位方差高斯会产生意想不到的结果

Python 处理特定的错误代码?

python - 设计带有列表的可扩展命令行界面

algorithm - 在二部图的一侧找到支配的顶点集

algorithm - 计算参加系列讲座的最少学生人数

algorithm - 为什么BFS用2种颜色对节点进行签名,而DFS用3种颜色对节点进行签名?

python - 如何将频谱图转换为 3d 图。 Python