我有数据
city inc pop edu crime cult
New-York 29343,00 8683,00 0,00 10,40 0,00
Moscow 25896,00 17496,00 0,00 10,20 1,0
Rome 21785,00 15063,00 0,00 14,20 1,00
London 20000,00 70453,00 1,00 18,00 1,00
Berlin 44057,00 57398,00 1,00 6,30 1,00
我尝试构建plot并给plot
命名,并将颜色更改为列
但它返回错误AttributeError: 'module' object has no attribute 'set_title'
和TypeError: 'AxesSubplot' object has no attribute '__getitem__'
您试图使用
AxesSubplot
类中的set_title
方法,但是您没有使用mpl面向对象的方法。有两种方法可以纠正这种情况:使用
plt.title('Salary and culture')
切换到更灵活的OO方法,并使用相关的
Axes
方法设置标题和轴标签,例如ax.set_title
,ax.set_xlabel
,等等。第二个错误的来源是,在对
pivot_table
调用.plot
时,返回的是matplotlibAxesSubplot
对象,而不是DataFrame
。因此,您尝试绘制result[[0]]
,它试图索引AxesSubplot
对象。在尝试为TypeError“return”type='dict'“error:”AxesSubplot'对象没有属性'getitem'
相关问题 更多 >
编程相关推荐