首页 > 解决方案 > 在 matplotlib 中传递用于绘图的元组会在第 1 行引发“元组对象不可调用”错误。3

问题描述

请在下面找到输出我正在使用 matplotlib 绘制图表,但 python 抛出错误“元组不可调用”

import matplotlib.pyplot as plt

fig, ax = plt.subplots(2, 2)

ax[0, 0].plot(range(10), 'r')
ax[1, 0].plot(range(10), 'b')
ax[0, 1].plot(range(10), 'g')
ax[1, 1].plot(range(10), 'k')
plt.show()

标签: pythonpython-3.xpandasmatplotlib

解决方案


请检查您的 python 版本,因为 range() 函数在 python 2 和 python 3 中的工作方式不同


推荐阅读