在Pycharm中调用matplotlib绘图时出现attributeerror :module ‘numbers’has no attribute integral错误。
原因是:同一个python代码文件夹里有一个名为numbers的代码文件(可能是自己之前的代码文件命名为numbers)。在调用matplotlib时,出现了混乱,方法:把自己编写的numbers 的文件删除或者把原来的numbers文件重命名后就可以执行了。
亲测有效
import matplotlib.pyplot as plt
input_values = [1, 2, 3, 4, 5]
cube = [1, 8, 27, 64, 125]
plt.plot(input_values, cube, linewidth=5)
#设置图表标题并给坐标轴加上标签
plt.title(‘Cube Numbers’, fontsize=24)
plt.xlabel(‘Value’, fontsize=14)
plt.ylabel(‘Cube of Value’,fontsize=14)
#设置刻度标记大小
plt.tick_params(axis = ‘both’,labelsize=14)
plt.show()
————————————
python编程从入门到实践书里的一段程序