Skip to main content
 首页 » 编程设计

python之在 matplotlib 中传递用于绘图的元组会在第 10 行抛出 "Tuple Object is not callable"错误。 3个

2024年11月01日10zdz8207

我正在使用 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() 

请您参考如下方法:

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